view_playlist.html 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% load static %}
  4. {% block content %}
  5. <div id="view_playlist">
  6. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'checkforupdates' %}" hx-trigger="load" hx-swap="outerHTML">
  7. </div>
  8. {% if playlist.has_playlist_changed %}
  9. <div hx-get="{% url 'update_playlist' playlist.playlist_id 'auto' %}" hx-trigger="load" hx-swap="outerHTML">
  10. <div class="alert alert-success alert-dismissible fade show" role="alert">
  11. {{ playlist.playlist_changed_text|linebreaksbr|default:"Looks like the playlist on YouTube was modified!" }}
  12. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  13. </div>
  14. <div class="d-flex justify-content-center mt-4 mb-3" id="loading-sign">
  15. <img src="{% static 'svg-loaders/circles.svg' %}" width="40" height="40">
  16. <h5 class="mt-2 ms-2">Updating playlist '{{ playlist.name }}', please wait!</h5>
  17. </div>
  18. </div>
  19. {% else %}
  20. <br>
  21. <div class="list-group-item list-group-item-action active">
  22. <div class="d-flex w-100 justify-content-between">
  23. <span>
  24. <h2 class="mb-1">{{ playlist.name }}
  25. <small>
  26. <input class="form-control me-1 visually-hidden" id="pl-{{ playlist.playlist_id }}" value="{{ playlist.playlist_id }}">
  27. <button class="copy-btn btn btn-light mb-1" data-clipboard-target="#pl-{{ playlist.playlist_id }}">
  28. <i class="far fa-copy" aria-hidden="true"></i>
  29. </button>
  30. </small> </h2>
  31. <h6>by {{ playlist.channel_name }}</h6>
  32. </span>
  33. <h4>
  34. <span id="notice-div">
  35. {% if playlist.marked_as != "none" %}
  36. <span class="badge bg-success text-white" >{{ playlist.marked_as|title }}</span>
  37. {% endif %}
  38. </span>
  39. </h4>
  40. </div>
  41. <p class="mb-1">
  42. {% if playlist.description %}
  43. <h5>{{ playlist.description|truncatewords:"50" }}</h5>
  44. {% else %}
  45. <h5>No description</h5>
  46. {% endif %}
  47. </p>
  48. <h6 class="">
  49. <span class="badge bg-light text-black-50">{% if playlist.is_user_owned %}OWNED{% else %}IMPORTED{% endif %}</span>
  50. <span class="badge bg-light text-black-50">{{ playlist.video_count }} VIDEOS</span>
  51. <span class="badge bg-light text-black-50">{{ playlist.playlist_duration }} </span>
  52. <span class="badge bg-light text-black-50">{% if playlist.is_private_on_yt %}PRIVATE{% else %}PUBLIC{% endif %}</span>
  53. {% if playlist.has_unavailable_videos %}
  54. <span class="badge bg-light text-black-50">SOME VIDEOS ARE UNAVAILABLE</span>
  55. {% endif %}
  56. {% if playlist.has_duplicate_videos %}
  57. <span class="badge bg-light text-black-50">DUPLICATE VIDEOS</span>
  58. {% endif %}
  59. </h6>
  60. </div>
  61. <br>
  62. <div id="row1">
  63. <div class="d-flex bd-highlight mb-1">
  64. <div class="me-auto bd-highlight">
  65. <div class="btn-toolbar mb-2 mb-md-0">
  66. <!--
  67. <div class="btn-group me-2">
  68. <button type="button" class="btn {% if playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">Grid</button>
  69. <button type="button" class="btn {% if not playlist.view_in_grid_mode %}btn-info {% else %}btn-outline-info{% endif %}">List</button>
  70. </div>
  71. -->
  72. <div class="btn-group me-2">
  73. <button type="button" class="btn btn-success dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  74. Sort By
  75. </button>
  76. <ul class="dropdown-menu">
  77. <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>
  78. <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>
  79. <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>
  80. <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>
  81. <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>
  82. <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>
  83. <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>
  84. <li><hr class="dropdown-divider"></li>
  85. <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>
  86. <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>
  87. </ul>
  88. </div>
  89. <div class="btn-group me-2">
  90. <button type="button" class="btn btn-warning dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
  91. Mark As
  92. </button>
  93. <ul class="dropdown-menu">
  94. <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>
  95. <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>
  96. <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>
  97. </ul>
  98. </div>
  99. </div>
  100. </div>
  101. <div class="bd-highlight">
  102. <div class="btn-toolbar mb-2 mb-md-0">
  103. <div class="btn-group me-2">
  104. <a hx-get="{% url 'update_playlist' playlist.playlist_id 'manual' %}" hx-target="#view_playlist" class="btn btn-secondary">
  105. <i class="fas fa-sync"></i>
  106. </a>
  107. </div>
  108. <div class="btn-group me-2">
  109. <button class="btn btn-warning" type="button" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'favorite' %}" hx-target="#playlist-fav">
  110. <div id="playlist-fav">
  111. {% if playlist.is_favorite %}
  112. <i class="fas fa-star"></i>
  113. {% else %}
  114. <i class="far fa-star"></i>
  115. {% endif %}
  116. </div>
  117. </button>
  118. </div>
  119. <div class="btn-group me-2">
  120. <a href="{% url 'view_playlist_settings' playlist.playlist_id %}" class="btn btn-primary">
  121. <i class="fas fa-cog"></i>
  122. </a>
  123. </div>
  124. <div class="btn-group me-2">
  125. <button type="button" class="btn btn-light" onclick="row1_hide()">Manage</button>
  126. </div>
  127. </div>
  128. </div>
  129. </div>
  130. </div>
  131. <div id="row2" style="display: none">
  132. <div class="d-flex bd-highlight mb-1">
  133. <div class="me-auto bd-highlight">
  134. <div class="btn-toolbar mb-2 mb-md-0">
  135. <div id="select-all-btn">
  136. <div class="btn-group me-2">
  137. <button type="button" class="btn btn-info" id="select-all-btn">Select All</button>
  138. </div>
  139. </div>
  140. <div id="deselect-all-btn" style="display: none">
  141. <div class="btn-group me-2">
  142. <button type="button" class="btn btn-info" id="select-all-btn">De-select All</button>
  143. </div>
  144. </div>
  145. <div class="btn-group me-2">
  146. <!-- <button type="submit" form="my-form" class="btn btn-outline-success" data-bs-toggle="dropdown" aria-expanded="false">
  147. Move
  148. </button> -->
  149. <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">
  150. {% if playlist.is_user_owned %}Move/{% endif %}Copy Videos
  151. </button>
  152. </div>
  153. <!--
  154. <div class="btn-group me-2">
  155. <button type="button" class="btn btn-outline-warning" data-bs-toggle="dropdown" aria-expanded="false">
  156. Mark/Unmark Favorite
  157. </button>
  158. </div>
  159. -->
  160. {% if playlist.is_user_owned %}
  161. <div class="btn-group me-2">
  162. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirm' %}" hx-include="[id='video-checkboxes']" hx-target="#delete-videos-confirm-box" type="button" id="delete-vids-btn" class="btn btn-danger" data-bs-toggle="collapse" data-bs-target="#deleteItemsCollapse" aria-expanded="false" aria-controls="deleteItemsCollapse">
  163. Delete Selected Videos
  164. </button>
  165. </div>
  166. {% endif %}
  167. </div>
  168. </div>
  169. <div class="bd-highlight">
  170. <div class="btn-toolbar mb-2 mb-md-0">
  171. <div class="btn-group me-2">
  172. <button type="button" class="btn btn-light" onclick="row1_show()" id="manageBtn">Manage</button>
  173. </div>
  174. </div>
  175. </div>
  176. </div>
  177. </div>
  178. <div id="row3" style="background-color: #0f5132">
  179. <div class="collapse border-danger" id="moveItemsToCollapse">
  180. <div class="card card-body bg-dark text-white-50">
  181. <h5>{% if playlist.is_user_owned %}Move or {% endif %}Copy videos to another playlist!</h5>
  182. <div class="d-flex justify-content-start">
  183. <input class="form-control w-50 bg-dark text-white border border-secondary" placeholder="Enter playlist ID or comma seperated list of playlist IDs here">
  184. {% if playlist.is_user_owned %}
  185. <div class="btn-group ms-2">
  186. <button type="button" class="btn btn-info" id="select-all-btn">Move!</button>
  187. </div>
  188. {% endif %}
  189. <div class="btn-group ms-2">
  190. <button type="button" class="btn btn-info" id="select-all-btn">Copy!</button>
  191. </div>
  192. </div>
  193. <div class="d-flex justify-content-start mt-3">
  194. <div class="btn-group">
  195. <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>
  196. </div>
  197. </div>
  198. </div>
  199. </div>
  200. </div>
  201. <div id="row4" style="background-color: #0f5132">
  202. <div class="collapse border-danger" id="deleteItemsCollapse">
  203. <div class="card card-body bg-dark text-white-50">
  204. <div id="delete-videos-confirm-box">
  205. <h5>Are you sure you want to delete these 40 items from your YouTube playlist? This cannot be undone.</h5>
  206. </div>
  207. <div class="d-flex justify-content-start">
  208. <div class="btn-group ms-2">
  209. <button hx-post="{% url 'delete_videos' playlist.playlist_id 'confirmed' %}" hx-include="[id='video-checkboxes']" type="button" class="btn btn-danger" id="select-all-btn">Yes!</button>
  210. </div>
  211. <div class="btn-group ms-2">
  212. <button type="button" class="btn btn-secondary" id="select-all-btn">Nvm</button>
  213. </div>
  214. <div class="btn-group ms-2">
  215. <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-primary">
  216. <i class="fas fa-sync"></i>
  217. </button>
  218. </div>
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. <div class="table-responsive" id="videos-div">
  224. <br>
  225. <div class="list-group" id="video-checkboxes">
  226. {% for video in videos %}
  227. <li class="list-group-item d-flex justify-content-between align-items-center bg-transparent" style="background-color: #40B3A2">
  228. {% if video.is_unavailable_on_yt and not video.was_deleted_on_yt %}
  229. <div class="d-flex justify-content-between align-items-center">
  230. <div>
  231. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ video.playlist_item_id }}" name="video-id">
  232. </div>
  233. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  234. <img src="https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg" class="img-fluid" alt="">
  235. </div>
  236. <div class="ms-4">
  237. <a class="link-dark" href="https://www.youtube.com/watch?v={{ video.video_id }}&list={{ video.playlist.playlist_id }}" target="_blank">
  238. {{ video.video_position }}. {{ video.name }}
  239. </a>
  240. <br><br>
  241. </div>
  242. </div>
  243. {% else %}
  244. <div class="d-flex justify-content-between align-items-center" >
  245. <div>
  246. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ video.playlist_item_id }}" name="video-id">
  247. </div>
  248. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  249. <img src="{% if video.thumbnail_url %}{{ video.thumbnail_url }}{% else %}https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg{% endif %}" class="img-fluid" alt="">
  250. </div>
  251. <div class="ms-4">
  252. {% if video.is_unavailable_on_yt and video.was_deleted_on_yt %}
  253. {{ video.video_position }}.
  254. <a class="link-dark" href="https://www.youtube.com/watch?v={{ video.video_id }}&list={{ video.playlist.playlist_id }}" target="_blank">
  255. {{ video.name|truncatewords:"16" }}
  256. </a>
  257. <br>
  258. <span class="badge bg-dark">VIDEO UNAVAILABLE</span>
  259. {% if video.video_details_modified %}<span class="badge bg-danger">UPDATED - {% if video.was_deleted_on_yt %}WENT PRIVATE/DELETED{% else %}NEWLY ADDED{% endif %}</span>{% endif %}
  260. <br><br>
  261. {% else %}
  262. {{ video.video_position }}.
  263. <a class="link-dark" href="https://www.youtube.com/watch?v={{ video.video_id }}&list={{ video.playlist.playlist_id }}" target="_blank">
  264. {{ video.name|truncatewords:"16" }}
  265. </a> by {{ video.channel_name }} <br>
  266. <span class="badge bg-secondary">{{ video.duration }}</span>
  267. {% if video.has_cc %}<span class="badge bg-secondary">CC</span>{% endif %}
  268. {% if video.published_at %}<span class="badge bg-secondary">{{ video.published_at }}</span>{% endif %}
  269. {% if video.view_count %}<span class="badge bg-info">{{ video.view_count|intword|intcomma }} views</span>{% endif %}
  270. {% if video.is_duplicate %}<span class="badge bg-primary">duplicate</span>{% endif %}
  271. {% if video.video_details_modified %}<span class="badge bg-danger">UPDATED - {% if video.was_deleted_on_yt %}WENT PRIVATE/DELETED{% else %}NEWLY ADDED{% endif %}</span>{% endif %}<br>
  272. <br>
  273. {% endif %}
  274. </div>
  275. </div>
  276. <div class="ms-5">
  277. {% if video.is_unavailable_on_yt and video.was_deleted_on_yt %}
  278. <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>
  279. <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">
  280. <div id="video-{{ forloop.counter }}-fav">
  281. {% if video.is_favorite %}
  282. <i class="fas fa-heart"></i>
  283. {% else %}
  284. <i class="far fa-heart"></i>
  285. {% endif %}
  286. </div>
  287. </button>
  288. {% else %}
  289. <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>
  290. <input class="form-control me-1 visually-hidden" id="video-{{ video.video_id }}" value="https://www.youtube.com/watch?v={{ video.video_id }}">
  291. <button class="copy-btn btn btn-sm btn-success mb-1" data-clipboard-target="#video-{{ video.video_id }}">
  292. <i class="far fa-copy" aria-hidden="true"></i>
  293. </button>
  294. <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>
  295. <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>
  296. <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">
  297. <div id="video-{{ forloop.counter }}-fav">
  298. {% if video.is_favorite %}
  299. <i class="fas fa-heart"></i>
  300. {% else %}
  301. <i class="far fa-heart"></i>
  302. {% endif %}
  303. </div>
  304. </button>
  305. {% if playlist.marked_as == "watching" %}
  306. <button class="btn btn-sm btn-light mb-1" type="button">
  307. <i class="far fa-check-circle"></i>
  308. </button>
  309. {% endif %}
  310. {% endif %}
  311. </div>
  312. {% endif %}
  313. </li>
  314. {% endfor %}
  315. </div>
  316. </div>
  317. {% endif %}
  318. </div>
  319. <!--
  320. <script src="{% static 'youtube-audio-player/iframe-api.js' %}"></script>
  321. <script src="{% static 'youtube-audio-player/yt.min.js' %}"></script>
  322. -->
  323. {% endblock %}