2
0

view_playlist.html 53 KB

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