2
0

view_playlist.html 46 KB

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