2
0

view_playlist.html 49 KB

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