view_playlist.html 46 KB

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