2
0

view_playlist.html 34 KB

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