view_playlist.html 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% load static %}
  4. {% block content %}
  5. <script src="{% static 'htmx/extensions/class-tools.js' %}" type="application/javascript"></script>
  6. <div id="view_playlist">
  7. {% if not_imported_LL %}
  8. <div hx-get="/import/liked-videos-playlist" hx-trigger="load" hx-swap="outerHTML">
  9. <div class="alert alert-dismissible fade show" role="alert" style="background-color: cadetblue">
  10. <div class="d-flex justify-content-center mt-4 mb-3 ms-2" id="loading-sign" >
  11. <img src="/static/svg-loaders/spinning-circles.svg" width="40" height="40">
  12. <h5 class="mt-2 ms-2 text-black">Importing your Liked Videos playlist into UnTube, do not refresh this page!</h5>
  13. </div>
  14. </div>
  15. </div>
  16. {% else %}
  17. {% if playlist.has_playlist_changed %}
  18. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'auto' %}" hx-trigger="load" hx-swap="outerHTML">
  19. <div class="d-flex justify-content-center mt-4 mb-3" id="loading-sign">
  20. <img src="{% static 'svg-loaders/circles.svg' %}" width="40" height="40" style="color: black">
  21. <h5 class="mt-2 ms-2">Updating playlist '{{ playlist.name }}', please wait!</h5>
  22. </div>
  23. </div>
  24. {% else %}
  25. <div class="sticky-top mb-3" style="top: 0.5rem;">
  26. {% if not playlist.is_yt_mix %}
  27. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'checkforupdates' %}" hx-trigger="load" hx-swap="outerHTML" id="checkforupdates">
  28. <div class="alert alert-info alert-dismissible fade show" role="alert">
  29. Checking playlist for updates...
  30. </div>
  31. </div>
  32. {% endif %}
  33. {% if playlist.marked_as == "watching" %}
  34. <div id="playlist-watch-message">
  35. {% include 'intercooler/playlist_watch_message.html' %}
  36. </div>
  37. {% endif %}
  38. </div>
  39. <div class="card text-white" style="max-width: 100%; background-color: #1A4464;">
  40. <div class="row g-0">
  41. <div class="col-md-4 p-3">
  42. <img class="img-fluid rounded-3" src="{{ playlist_items.0.video.thumbnail_url }}" style="max-width:100%; height: auto; object-fit: cover;">
  43. </div>
  44. <div class="col-md-8">
  45. <div class="card-body">
  46. <div class="d-flex justify-content-between">
  47. <h2 class="card-title text-white">
  48. <a href="https://www.youtube.com/playlist?list={{ playlist.playlist_id }}" target="_blank" style="color: white; text-decoration: none">{{ playlist.name }}</a>
  49. <br><small class="h4">{% if playlist.user_label %}a.k.a <span style="border-bottom: 3px #ffffff dashed;"> {{ playlist.user_label }}</span>{% endif %}</small>
  50. </h2>
  51. <h4>
  52. <span id="notice-div">
  53. {% if playlist.marked_as != "none" %}
  54. <span class="badge bg-success text-white" >
  55. {% if playlist.marked_as == "watching" %}
  56. <i class="fas fa-fire-alt me-1"></i>
  57. {% elif playlist.marked_as == "plan-to-watch"%}
  58. <i class="fas fa-flag me-1"></i>
  59. {% endif %}
  60. {{ playlist.marked_as }}
  61. </span>
  62. {% endif %}
  63. </span>
  64. <span id="">
  65. <span class="badge bg-dark">
  66. <i class="fas fa-map-pin"></i>
  67. </span>
  68. </span>
  69. </h4>
  70. </div>
  71. <h6>by {{ playlist.channel_name }}</h6>
  72. <p class="card-text">
  73. {% if playlist.description %}
  74. <h5 class="overflow-auto" style="max-height: 350px;">
  75. {{ playlist.description|linebreaksbr|urlize }}
  76. </h5>
  77. {% else %}
  78. <h5>No description</h5>
  79. {% endif %}
  80. </p>
  81. <h6 class="h6 text-uppercase overflow-auto">
  82. <span class="badge bg-light text-black-50">{% if playlist.is_user_owned %}OWNED{% else %}IMPORTED{% endif %}</span>
  83. <span class="badge bg-light text-black-50">{{ playlist.video_count }} VIDEOS</span>
  84. <span class="badge bg-light text-black-50">{{ playlist.playlist_duration }} </span>
  85. <span class="badge bg-light text-black-50">{% if playlist.is_private_on_yt %}PRIVATE{% else %}PUBLIC{% endif %}</span>
  86. {% if playlist.is_yt_mix %}<span class="badge bg-light text-black-50">YT MIX</span>{% endif %}
  87. {% if playlist.has_unavailable_videos %}
  88. <span class="badge bg-light text-black-50">
  89. {% if playlist.get_watchable_videos_count == 0 %}
  90. ALL
  91. {% else %}
  92. {{ playlist.get_unavailable_videos_count }}
  93. {% endif %}
  94. VIDEOS ARE UNAVAILABLE
  95. </span>
  96. {% endif %}
  97. {% if playlist.has_duplicate_videos %}
  98. <span class="badge bg-light text-black-50">{{ playlist.get_duplicate_videos_count }} DUPLICATE VIDEOS</span>
  99. {% endif %}
  100. <a data-bs-toggle="collapse" href="#channelVidsChartCollapse" role="button" aria-expanded="false" aria-controls="channelVidsChartCollapse">
  101. <span class="badge bg-light text-black-50">{{ playlist.get_channels_list.0 }} channels</span>
  102. </a>
  103. <div class="collapse" id="channelVidsChartCollapse">
  104. <div class="card card-body bg-transparent text-white border border-3 mt-2 border-light">
  105. <canvas id="channel-videos-chart" data-url="{% url 'channel_videos_distribution' playlist.playlist_id %}"></canvas>
  106. </div>
  107. </div>
  108. </h6>
  109. <h6 class="h6 pt-1">
  110. Tags:
  111. <span class="text-uppercase" >
  112. <span id="playlist-tags">
  113. {% for tag in playlist_tags %}
  114. <span id="tag-{{ tag.name|slugify }}" class="mb-2">
  115. <span class="badge rounded-pill bg-info mb-lg-2">
  116. <a href="{% url 'tagged_playlists' tag.name %}" style="text-decoration: none; color: #114f7f">{{ tag.name }} </a>
  117. <a class="ms-1" hx-post="{% url 'remove_playlist_tag' playlist.playlist_id tag.name %}" hx-trigger="click" hx-target="#tag-{{ tag.name|slugify }}"><i class="fas fa-times-circle"></i></a>
  118. </span>
  119. </span>
  120. {% endfor %}
  121. </span>
  122. <a data-bs-toggle="collapse" href="#addTagsCollapse" role="button" aria-expanded="false" aria-controls="addTagsCollapse">
  123. <span class="badge rounded-pill bg-warning mb-lg-2"><i class="fas fa-plus"></i></span>
  124. </a>
  125. </span>
  126. <div class="collapse" id="addTagsCollapse">
  127. <div class="card card-body bg-dark text-white border border-4 mt-1 border-warning">
  128. <h5>Add a tag to this playlist</h5>
  129. {% if unused_tags %}
  130. <div class="d-flex justify-content-start mt-2">
  131. <select class="form-select w-50 bg-dark text-white border border-secondary" name="playlistTag" hx-get="{% url 'get_unused_playlist_tags' playlist.playlist_id %}" hx-trigger="click" hx-target="#unused-playlist-tags">
  132. <option selected>Pick from existing unused tags</option>
  133. <span id="unused-playlist-tags">
  134. {% for tag in unused_tags %}
  135. <option value="{{ tag.name }}">{{ tag.name }}</option>
  136. {% endfor %}
  137. </span>
  138. </select>
  139. <div class="btn-group ms-2">
  140. <button type="button" class="btn btn-warning" hx-post="{% url 'add_playlist_tag' playlist.playlist_id %}" hx-trigger="click" hx-include="[name='playlistTag']" hx-target="this">Add Tag</button>
  141. </div>
  142. </div>
  143. <div class="d-flex justify-content-start mt-3 mb-2">
  144. - OR -
  145. </div>
  146. {% endif %}
  147. <div class="d-flex justify-content-start mt-2">
  148. <input class="form-control w-50 bg-dark text-white border border-secondary" placeholder="Enter a new tag name here" name="createTagField">
  149. <div class="btn-group ms-2">
  150. <button type="button" class="btn btn-warning" hx-post="{% url 'create_playlist_tag' playlist.playlist_id %}" hx-trigger="click" hx-include="[name='createTagField']" hx-target="this">Create & Add Tag</button>
  151. </div>
  152. </div>
  153. </div>
  154. </div>
  155. </h6>
  156. <p class="card-text text-white-50"><small>Last updated {{ playlist.updated_at|naturalday }}</small> &bullet; <small>{{ playlist.num_of_accesses }} clicks </small></p>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. <br>
  162. <div id="row1">
  163. <div class="d-flex bd-highlight mb-1">
  164. <div class="me-auto bd-highlight">
  165. <div class="btn-toolbar mb-2 mb-md-0">
  166. <!--
  167. <div class="btn-group me-2">
  168. <button type="button" class="btn {% if playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">Grid</button>
  169. <button type="button" class="btn {% if not playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">List</button>
  170. </div>
  171. -->
  172. <div class="btn-group me-2 mb-2">
  173. <button type="button" class="btn btn-warning dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  174. Mark As
  175. </button>
  176. <ul class="dropdown-menu">
  177. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'none' %}" hx-trigger="click" hx-target="#notice-div">None</button></li>
  178. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'watching' %}" hx-trigger="click" hx-target="#notice-div">Watching</button></li>
  179. <li><button class="dropdown-item" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'plan-to-watch' %}" hx-trigger="click" hx-target="#notice-div">Plan to Watch</button></li>
  180. </ul>
  181. </div>
  182. {% if playlist_items.count != 0 %}
  183. <div class="btn-group me-2 mb-2">
  184. <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  185. Sort By
  186. </button>
  187. <ul class="dropdown-menu">
  188. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'all' %}" hx-trigger="click" hx-target="#videos-div">All</button></li>
  189. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'favorites' %}" hx-trigger="click" hx-target="#videos-div">Favorites</button></li>
  190. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'popularity' %}" hx-trigger="click" hx-target="#videos-div">Popularity</button></li>
  191. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'date-published' %}" hx-trigger="click" hx-target="#videos-div">Date Published</button></li>
  192. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'views' %}" hx-trigger="click" hx-target="#videos-div">Views</button></li>
  193. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'has-cc' %}" hx-trigger="click" hx-target="#videos-div">Has CC</button></li>
  194. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'duration' %}" hx-trigger="click" hx-target="#videos-div">Duration</button></li>
  195. <li><hr class="dropdown-divider"></li>
  196. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'new-updates' %}" hx-trigger="click" hx-target="#videos-div">Updates</button></li>
  197. <li><button class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'unavailable-videos' %}" hx-trigger="click" hx-target="#videos-div">Unavailable</button></li>
  198. </ul>
  199. </div>
  200. <div class="btn-group me-2 mb-2">
  201. {% with channels=playlist.get_channels_list %}
  202. <button type="button" class="btn btn-info dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  203. {{ channels.0 }} Channels
  204. </button>
  205. <ul class="dropdown-menu">
  206. {% for channel in channels.1 %}
  207. <li><a class="dropdown-item" hx-get="{% url 'order_playlist_by' playlist.playlist_id 'channel' %}" hx-vals='{"channel-name": "{{ channel }}"}' hx-trigger="click" hx-target="#videos-div">{{ channel }}</a></li>
  208. {% endfor %}
  209. </ul>
  210. {% endwith %}
  211. </div>
  212. {% endif %}
  213. </div>
  214. </div>
  215. <div class="bd-highlight">
  216. <div class="btn-toolbar mb-2 mb-md-0 overflow-auto">
  217. <div class="btn-group me-2 mb-2">
  218. <a hx-get="{% url 'update_playlist' playlist.playlist_id 'manual' %}" hx-target="#view_playlist" class="btn btn-secondary">
  219. <i class="fas fa-sync"></i>
  220. </a>
  221. </div>
  222. <div class="btn-group me-2 mb-2">
  223. <button class="btn btn-warning" type="button" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'favorite' %}" hx-target="#playlist-fav">
  224. <div id="playlist-fav">
  225. {% if playlist.is_favorite %}
  226. <i class="fas fa-star"></i>
  227. {% else %}
  228. <i class="far fa-star"></i>
  229. {% endif %}
  230. </div>
  231. </button>
  232. </div>
  233. <div class="btn-group me-2 mb-2">
  234. <a href="{% url 'view_playlist_settings' playlist.playlist_id %}" class="btn btn-primary">
  235. <i class="fas fa-cog"></i>
  236. </a>
  237. </div>
  238. {% if playlist_items.count != 0 %}
  239. <div class="btn-group me-2 mb-2">
  240. <button type="button" class="btn btn-light" onclick="row1_hide()">Manage</button>
  241. </div>
  242. {% endif %}
  243. </div>
  244. </div>
  245. </div>
  246. </div>
  247. <div id="row2" style="display: none">
  248. <div class="d-flex bd-highlight mb-1">
  249. <div class="me-auto bd-highlight">
  250. <div class="btn-toolbar mb-2 mb-md-0">
  251. <div id="select-all-btn">
  252. <div class="btn-group me-2 mb-2">
  253. <button type="button" class="btn btn-info" id="select-all-btn">Select All</button>
  254. </div>
  255. </div>
  256. <div id="deselect-all-btn" style="display: none">
  257. <div class="btn-group me-2 mb-2">
  258. <button type="button" class="btn btn-info" id="select-all-btn">De-select All</button>
  259. </div>
  260. </div>
  261. <div class="btn-group me-2 mb-2">
  262. <!-- <button type="submit" form="my-form" class="btn btn-outline-success" data-bs-toggle="dropdown" aria-expanded="false">
  263. Move
  264. </button> -->
  265. <button class="btn btn-success" id="move-copy-vids-btn" type="button" data-bs-toggle="collapse" data-bs-target="#moveItemsToCollapse" aria-expanded="false" aria-controls="moveItemsToCollapse">
  266. {% if playlist.is_user_owned %}Move/{% endif %}Copy Videos
  267. </button>
  268. </div>
  269. <!--
  270. <div class="btn-group me-2">
  271. <button type="button" class="btn btn-outline-warning" data-bs-toggle="dropdown" aria-expanded="false">
  272. Mark/Unmark Favorite
  273. </button>
  274. </div>
  275. -->
  276. {% if playlist.is_user_owned %}
  277. <div class="btn-group me-2 mb-2">
  278. <button class="btn btn-danger" data-bs-toggle="collapse" data-bs-target="#deleteItemsCollapse" aria-expanded="false" aria-controls="deleteItemsCollapse">
  279. Delete Videos
  280. </button>
  281. </div>
  282. {% endif %}
  283. </div>
  284. </div>
  285. <div class="bd-highlight">
  286. <div class="btn-toolbar mb-2 mb-md-0">
  287. <div class="btn-group me-2 mb-2">
  288. <button class="btn btn-primary" data-bs-toggle="collapse" data-bs-target="#deleteItemsCollapse" aria-expanded="false" aria-controls="deleteItemsCollapse">
  289. <i class="fa fa-history"></i> History
  290. </button>
  291. </div>
  292. <div class="btn-group me-2 mb-2">
  293. <button type="button" class="btn btn-light" onclick="row1_show()" id="manageBtn">Manage</button>
  294. </div>
  295. </div>
  296. </div>
  297. </div>
  298. </div>
  299. <div id="row3" style="background-color: #0f5132">
  300. <div class="collapse border-danger" id="moveItemsToCollapse">
  301. <div class="card card-body bg-dark text-white">
  302. <h5>{% if playlist.is_user_owned %}Move or {% endif %}Copy videos to other playlist(s)!</h5>
  303. <div class="row d-flex justify-content-start">
  304. <div class="col-md-6 text-dark">
  305. <select class="visually-hidden"
  306. id="playlists-to-move-to" name="playlist-ids" placeholder="Select Playlists" multiple>
  307. {% for pl in user_owned_playlists %}
  308. {% if pl.playlist_id != playlist.playlist_id %}
  309. <option value="{{ pl.playlist_id }}" class="text-dark">{{ pl.name }}</option>
  310. {% endif %}
  311. {% endfor %}
  312. </select>
  313. </div>
  314. <div class="col-md d-flex justify-content-start">
  315. <div class="htmx-indicator d-flex align-items-center" id="move-copy-loader">
  316. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  317. <span class="mt-2 ms-2">Loading, please wait... </span>
  318. </div>
  319. </div>
  320. </div>
  321. <div class="d-flex justify-content-start mt-2">
  322. {% if playlist.is_user_owned %}
  323. <div class="btn-group mt-1">
  324. <button hx-indicator="#move-copy-loader" hx-post="{% url 'playlist_move_copy_videos' playlist.playlist_id 'move' %}" hx-include="#playlists-to-move-to, #video-checkboxes" hx-target="#move-copy-videos-box" type="button" class="btn btn-primary">
  325. Move!
  326. </button>
  327. </div>
  328. {% endif %}
  329. <div class="btn-group ms-1 mt-1">
  330. <button hx-indicator="#move-copy-loader" hx-post="{% url 'playlist_move_copy_videos' playlist.playlist_id 'copy' %}" hx-include="#playlists-to-move-to, #video-checkboxes" hx-target="#move-copy-videos-box" type="button" class="btn btn-info">
  331. Copy!
  332. </button>
  333. </div>
  334. <div id="move-copy-videos-box" class="d-flex align-items-end ms-2">
  335. <span class="text-warning">Note: Move will delete the selected videos from this playlist. Copy won't.</span>
  336. </div>
  337. </div>
  338. </div>
  339. </div>
  340. </div>
  341. <div id="row4" style="background-color: #0f5132">
  342. <div class="collapse border-danger" id="deleteItemsCollapse">
  343. <div class="card card-body bg-dark text-white-50">
  344. <div id="delete-videos-confirm-box">
  345. {% if not playlist.confirm_before_deleting %}
  346. <h5>Note: You have set confirm before deleting to False. Buttons below will take effect immediately when clicked.</h5>
  347. <hr>
  348. {% endif %}
  349. </div>
  350. <div class="d-flex justify-content-start">
  351. <div class="btn-group me-2">
  352. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirm' %}" hx-include="[id='video-checkboxes']" hx-vals='{"confirm before deleting": "{{ playlist.confirm_before_deleting }}"}' hx-target="#delete-videos-confirm-box" type="button" class="btn btn-primary">
  353. Delete Selected
  354. </button>
  355. </div>
  356. {% if playlist.has_unavailable_videos %}
  357. <div class="btn-group me-2">
  358. <button hx-post="{% url 'delete_specific_videos' playlist.playlist_id 'unavailable' %}" hx-target="#delete-videos-confirm-box" type="button" class="btn btn-info" hx-indicator="#delete-loader">
  359. Delete {{ playlist.get_unavailable_videos_count }} Unavailable Videos
  360. </button>
  361. </div>
  362. {% endif %}
  363. {% if playlist.has_duplicate_videos %}
  364. <div class="btn-group me-2">
  365. <button hx-post="{% url 'delete_specific_videos' playlist.playlist_id 'duplicate' %}" hx-target="#delete-videos-confirm-box" type="button" class="btn btn-warning" hx-indicator="#delete-loader">
  366. Delete {{ playlist.get_duplicate_videos_count }} Duplicate Videos
  367. </button>
  368. </div>
  369. {% endif %}
  370. <div class="btn-group me-2">
  371. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirm' %}" hx-vals='{"all": "yes", "confirm before deleting": "{{ playlist.confirm_before_deleting }}"}' hx-target="#delete-videos-confirm-box" type="button" class="btn btn-danger">
  372. Empty this Playlist
  373. </button>
  374. </div>
  375. <div class="htmx-indicator d-flex align-items-center" id="delete-loader">
  376. <img src="{% static 'svg-loaders/grid.svg' %}" width="25" height="25" class="ms-2 mt-2">
  377. <span class="mt-2 ms-2">Deleting, please wait... </span>
  378. </div>
  379. </div>
  380. </div>
  381. </div>
  382. </div>
  383. <div class="table-responsive" id="videos-div">
  384. <br>
  385. {% if playlist_items %}
  386. <div class="list-group" id="video-checkboxes">
  387. {% for playlist_item in playlist_items|slice:"0:50" %}
  388. <li id="{{ playlist_item.playlist_item_id }}" onclick="selectVideo(this);" {% if forloop.last and playlist_items.count > 50 %}hx-get="{% url 'load_more_videos' playlist.playlist_id order_by|default:"all" page|default:"1" %}"
  389. hx-trigger="revealed"
  390. hx-swap="afterend" hx-indicator="#load-more-videos-spinner" {% endif %} class="list-group-item d-flex justify-content-between align-items-center bg-transparent videos" style="background-color: #40B3A2">
  391. {% if playlist_item.video.is_unavailable_on_yt and not playlist_item.video.was_deleted_on_yt %}
  392. <div class="d-flex justify-content-between align-items-center">
  393. <div>
  394. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ playlist_item.playlist_item_id }}" id="video-{{ playlist_item.playlist_item_id }}" name="video-id">
  395. </div>
  396. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  397. <img src="https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg" class="img-fluid" alt="">
  398. </div>
  399. <div class="ms-4">
  400. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  401. {{ playlist_item.video_position|add:"1" }}. {{ playlist_item.video.name }}
  402. </a>
  403. <br><br>
  404. </div>
  405. </div>
  406. {% else %}
  407. <div class="d-flex justify-content-between align-items-center" >
  408. <div>
  409. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ playlist_item.playlist_item_id }}" id="video-{{ playlist_item.playlist_item_id }}" name="video-id">
  410. </div>
  411. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  412. <img src="{% if playlist_item.video.thumbnail_url %}{{ playlist_item.video.thumbnail_url }}{% else %}https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg{% endif %}" class="img-fluid" alt="">
  413. </div>
  414. <div class="ms-4">
  415. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  416. {{ playlist_item.video_position|add:"1" }}.
  417. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  418. {{ playlist_item.video.name|truncatewords:"16" }}
  419. </a>
  420. <br>
  421. <span class="badge bg-dark">VIDEO UNAVAILABLE</span>
  422. {% if playlist_item.video.video_details_modified %}<span class="badge bg-danger">WENT PRIVATE/DELETED {{ playlist_item.video.updated_at|naturaltime|upper }}</span>{% endif %}
  423. <br><br>
  424. {% else %}
  425. {{ playlist_item.video_position|add:"1" }}.
  426. <a class="link-dark" href="{% url 'video' playlist_item.video.video_id %}">
  427. {{ playlist_item.video.name|truncatewords:"16" }}
  428. </a> by {{ playlist_item.video.channel_name }} <br>
  429. <span class="badge bg-secondary">{{ playlist_item.video.duration }}</span>
  430. {% if playlist_item.video.has_cc %}<span class="badge bg-danger">CC</span>{% endif %}
  431. {% if playlist_item.video.published_at %}<span class="badge bg-secondary">added to playlist on {{ playlist_item.published_at }}</span>{% endif %}
  432. <span class="badge bg-info text-black-50"><i class="fas fa-eye"></i> {% if playlist_item.video.view_count == -1 %}HIDDEN{% else %}{{ playlist_item.video.view_count|intword|intcomma }}{% endif %}</span>
  433. <span class="badge bg-warning text-black-50"><i class="fas fa-thumbs-up"></i> {% if playlist_item.video.like_count == -1 %}HIDDEN{% else %}{{ playlist_item.video.like_count|intword|intcomma }}{% endif %}</span>
  434. {% if playlist_item.is_duplicate %}<span class="badge bg-primary">duplicate</span>{% endif %}
  435. {% if playlist_item.video.playlists.count|add:"-1" != 0 %}<span class="badge bg-dark"><a href="{% url 'video' playlist_item.video.video_id %}#found-in" style="text-decoration: none; color: white">found in {{ playlist_item.video.playlists.count|add:"-1" }} other playlist{% if playlist_item.video.playlists.count|add:"-1" > 1 %}s{% endif %}</a></span>{% endif %}
  436. {% if playlist_item.video.video_details_modified %}<span class="badge bg-danger">{% if playlist_item.video.was_deleted_on_yt %}went private/deleted{% else %}added{% endif %} {{ playlist_item.created_at|naturaltime }}</span>{% endif %}<br>
  437. <br>
  438. {% endif %}
  439. </div>
  440. </div>
  441. <div class="ms-5">
  442. {% if playlist_item.video.is_unavailable_on_yt or playlist_item.video.was_deleted_on_yt %}
  443. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  444. <button class="btn btn-sm btn-dark mb-1" type="button" hx-get="{% url 'mark_video_favorite' playlist.playlist_id playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-fav">
  445. <div id="video-{{ forloop.counter }}-fav">
  446. {% if playlist_item.video.is_favorite %}
  447. <i class="fas fa-heart" style="color: #fafa06"></i>
  448. {% else %}
  449. <i class="far fa-heart"></i>
  450. {% endif %}
  451. </div>
  452. </button>
  453. {% else %}
  454. <a class="btn btn-sm btn-info mb-1" type="button" href="https://www.youtube.com/watch?v={{ playlist_item.video.video_id }}&list={{ playlist.playlist_id }}" class="btn btn-info me-1" target="_blank"><i class="fas fa-external-link-alt" aria-hidden="true"></i></a>
  455. <input class="form-control me-1 visually-hidden" id="video-{{ playlist_item.video.video_id }}" value="https://www.youtube.com/watch?v={{ playlist_item.video.video_id }}">
  456. <button class="copy-btn btn btn-sm btn-success mb-1" data-clipboard-target="#video-{{ playlist_item.video.video_id }}">
  457. <i class="far fa-copy" aria-hidden="true"></i>
  458. </button>
  459. <a class="btn btn-sm btn-primary mb-1" href="{% url 'video' playlist_item.video.video_id %}"><i class="fas fa-info"></i></a>
  460. <button class="btn btn-sm btn-dark mb-1" type="button" hx-get="{% url 'mark_video_favorite' playlist.playlist_id playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-fav">
  461. <div id="video-{{ forloop.counter }}-fav">
  462. {% if playlist_item.video.is_favorite %}
  463. <i class="fas fa-heart" style="color: #fafa06"></i>
  464. {% else %}
  465. <i class="far fa-heart"></i>
  466. {% endif %}
  467. </div>
  468. </button>
  469. {% if playlist.marked_as == "watching" and not playlist_item.is_duplicate %}
  470. <button class="btn btn-sm btn-light mb-1" type="button" hx-get="{% url 'mark_video_watched' playlist.playlist_id playlist_item.video.video_id %}" hx-target="#video-{{ forloop.counter }}-watched">
  471. <div id="video-{{ forloop.counter }}-watched">
  472. {% if playlist_item.video.is_marked_as_watched %}
  473. <i class="fas fa-check-circle"></i>
  474. {% else %}
  475. <i class="far fa-check-circle"></i>
  476. {% endif %}
  477. </div>
  478. </button>
  479. {% endif %}
  480. {% endif %}
  481. </div>
  482. {% endif %}
  483. </li>
  484. {% endfor %}
  485. </div>
  486. {% else %}
  487. <div class="card bg-dark text-white mb-3">
  488. <div class="card-body">
  489. <div class="d-flex justify-content-center align-content-center">
  490. Playlist is empty ;-;
  491. </div>
  492. <div class="d-flex justify-content-center align-content-center">
  493. Consider moving/copying videos from other playlists into this playlist by copying and using this playlist's ID.
  494. </div>
  495. </div>
  496. </div>
  497. {% endif %}
  498. </div>
  499. {% endif %}
  500. <div class="d-flex justify-content-center">
  501. <img id="load-more-videos-spinner" class="htmx-indicator mt-4" src="{% static 'svg-loaders/spinning-circles.svg' %}" width="40" height="40">
  502. </div>
  503. {% endif %}
  504. </div>
  505. <button class="scrollToTopBtn sticky-top">
  506. <i class="fa fa-angle-double-up fa-lg"></i></button>
  507. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  508. <script type="application/javascript">
  509. $(document).ready(function(){
  510. // multiple choices select search box
  511. var multipleCancelButton = new Choices('#playlists-to-move-to', {
  512. removeItemButton: true,
  513. });
  514. BackgroundCheck.init({
  515. targets: '.ui',
  516. images: '.ui-img'
  517. });
  518. });
  519. $(function () {
  520. var $populationChart = $("#channel-videos-chart");
  521. $.ajax({
  522. url: $populationChart.data("url"),
  523. success: function (data) {
  524. var ctx = $populationChart[0].getContext("2d");
  525. var coloR = [];
  526. var dynamicColors = function() { // generate random color
  527. var r = Math.floor(Math.random() * 255);
  528. var g = Math.floor(Math.random() * 255);
  529. var b = Math.floor(Math.random() * 255);
  530. return "rgb(" + r + "," + g + "," + b + ")";
  531. };
  532. for (var i in data.labels) {
  533. if (data.labels)
  534. coloR.push(dynamicColors());
  535. }
  536. new Chart(ctx, {
  537. type: 'pie',
  538. data: {
  539. labels: data.labels,
  540. datasets: [{
  541. label: 'Videos',
  542. backgroundColor: coloR,
  543. data: data.data
  544. }]
  545. },
  546. options: {
  547. responsive: true,
  548. legend: {
  549. position: 'right',
  550. display: false
  551. },
  552. title: {
  553. display: true,
  554. text: 'Video Count Distribution per Channel',
  555. fontSize: 20,
  556. fontColor: '#fff',
  557. },
  558. }
  559. });
  560. }
  561. });
  562. });
  563. // when a video list item is clicked on, it gets checked and its bg turns red
  564. function selectVideo(video) {
  565. if ($('#row2').is(':visible')) {
  566. var videoCB = document.getElementById("video-" + video.id);
  567. if (videoCB.checked) {
  568. video.classList.remove("bg-danger");
  569. video.classList.add("bg-transparent");
  570. videoCB.checked = false;
  571. } else {
  572. video.classList.remove("bg-transparent");
  573. video.classList.add("bg-danger");
  574. videoCB.checked = true;
  575. }
  576. }
  577. }
  578. var moveCopyBtn = document.getElementById('move-copy-vids-btn');
  579. var moveCopyCollapse = document.getElementById('moveItemsToCollapse');
  580. var bsMoveCopyCollapse = new bootstrap.Collapse(moveCopyCollapse, {
  581. toggle: false
  582. });
  583. var deleteBtn = document.getElementById('delete-vids-btn');
  584. var deleteCollapse = document.getElementById('deleteItemsCollapse');
  585. var bsDeleteCollapse = new bootstrap.Collapse(deleteCollapse, {
  586. toggle: false
  587. });
  588. document.getElementById('manageBtn').addEventListener('click', function () { document.getElementById("delete-videos-confirm-box").innerHTML = "";
  589. document.getElementById("delete-videos-confirm-box").innerHTML = "";
  590. bsMoveCopyCollapse.hide();
  591. bsDeleteCollapse.hide();
  592. });
  593. moveCopyCollapse.addEventListener('show.bs.collapse', function () {
  594. bsDeleteCollapse.hide();
  595. });
  596. deleteCollapse.addEventListener('show.bs.collapse', function () {
  597. bsMoveCopyCollapse.hide();
  598. });
  599. <!-- end -->
  600. document.getElementById('select-all-btn').onclick = function() {
  601. document.getElementById('select-all-btn').style.display = "none";
  602. document.getElementById('deselect-all-btn').style.display = "block";
  603. var checkboxes = document.getElementsByClassName('video-checkboxes');
  604. for (var checkbox of checkboxes) {
  605. checkbox.checked = true;
  606. }
  607. var listItems = document.getElementsByClassName('videos'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  608. for(var i=0, len=listItems.length; i<len; i++)
  609. {
  610. if(listItems[i].classList.contains("bg-transparent")){
  611. listItems[i].classList.remove("bg-transparent");
  612. listItems[i].classList.add("bg-danger");
  613. }
  614. }
  615. }
  616. document.getElementById('deselect-all-btn').onclick = function() {
  617. document.getElementById('deselect-all-btn').style.display = "none";
  618. document.getElementById('select-all-btn').style.display = "block";
  619. var checkboxes = document.getElementsByClassName('video-checkboxes');
  620. for (var checkbox of checkboxes) {
  621. checkbox.checked = false;
  622. }
  623. var listItems = document.getElementsByClassName('videos'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  624. for(var i=0, len=listItems.length; i<len; i++)
  625. {
  626. if(listItems[i].classList.contains("bg-danger")){
  627. listItems[i].classList.remove("bg-danger");
  628. listItems[i].classList.add("bg-transparent");
  629. }
  630. }
  631. }
  632. function row1_hide() {
  633. document.getElementById("row1").style.display = "none";
  634. var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  635. for(var i=0, len=checkboxes.length; i<len; i++)
  636. {
  637. //checkboxes[i].style.display = "block";
  638. checkboxes[i].checked = false;
  639. }
  640. document.getElementById("row2").style.display = "block";
  641. }
  642. function row1_show() {
  643. document.getElementById("row1").style.display = "block";
  644. var checkboxes = document.getElementsByClassName('video-checkboxes'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  645. for(var i=0, len=checkboxes.length; i<len; i++)
  646. {
  647. checkboxes[i].style.display = "none";
  648. checkboxes[i].checked = false;
  649. }
  650. document.getElementById("row2").style.display = "none";
  651. var listItems = document.getElementsByClassName('videos'); //Cache the collection here, so that even a new element added with the same class later we can avoid querying this again by using the cached collection.
  652. for(var i=0, len=listItems.length; i<len; i++)
  653. {
  654. if(listItems[i].classList.contains("bg-danger")){
  655. listItems[i].classList.remove("bg-danger");
  656. listItems[i].classList.add("bg-transparent");
  657. }
  658. }
  659. }
  660. function select_all_checkboxes(source) {
  661. checkboxes = document.getElementsByClassName('big-checkbox');
  662. for(var i=0, n=checkboxes.length;i<n;i++) {
  663. checkboxes[i].checked = source.checked;
  664. }
  665. }
  666. </script>
  667. <!--
  668. <script src="{% static 'youtube-audio-player/iframe-api.js' %}"></script>
  669. <script src="{% static 'youtube-audio-player/yt.min.js' %}"></script>
  670. -->
  671. {% endblock %}