view_playlist.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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. {% if playlist.is_user_owned %}
  109. <div class="btn-group me-2">
  110. <button type="button" class="btn btn-danger">
  111. <i class="fas fa-dumpster-fire"></i>
  112. </button>
  113. </div>
  114. <div class="btn-group me-2">
  115. <button type="button" class="btn btn-primary">
  116. <i class="fas fa-edit"></i>
  117. </button>
  118. </div>
  119. {% endif %}
  120. <div class="btn-group me-2">
  121. <button class="btn btn-warning" type="button" hx-get="{% url 'mark_playlist_as' playlist.playlist_id 'favorite' %}" hx-target="#playlist-fav">
  122. <div id="playlist-fav">
  123. {% if playlist.is_favorite %}
  124. <i class="fas fa-star"></i>
  125. {% else %}
  126. <i class="far fa-star"></i>
  127. {% endif %}
  128. </div>
  129. </button>
  130. </div>
  131. <div class="btn-group me-2">
  132. <button type="button" class="btn btn-light" onclick="row1_hide()">Manage</button>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </div>
  138. <div id="row2" style="display: none">
  139. <div class="d-flex bd-highlight mb-1">
  140. <div class="me-auto bd-highlight">
  141. <div class="btn-toolbar mb-2 mb-md-0">
  142. <div id="select-all-btn">
  143. <div class="btn-group me-2">
  144. <button type="button" class="btn btn-info" id="select-all-btn">Select All</button>
  145. </div>
  146. </div>
  147. <div id="deselect-all-btn" style="display: none">
  148. <div class="btn-group me-2">
  149. <button type="button" class="btn btn-info" id="select-all-btn">De-select All</button>
  150. </div>
  151. </div>
  152. <div class="btn-group me-2">
  153. <!-- <button type="submit" form="my-form" class="btn btn-outline-success" data-bs-toggle="dropdown" aria-expanded="false">
  154. Move
  155. </button> -->
  156. <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">
  157. Move/Copy Videos
  158. </button>
  159. </div>
  160. <!--
  161. <div class="btn-group me-2">
  162. <button type="button" class="btn btn-outline-warning" data-bs-toggle="dropdown" aria-expanded="false">
  163. Mark/Unmark Favorite
  164. </button>
  165. </div>
  166. -->
  167. <div class="btn-group me-2">
  168. <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">
  169. Delete Selected
  170. </button>
  171. </div>
  172. </div>
  173. </div>
  174. <div class="bd-highlight">
  175. <div class="btn-toolbar mb-2 mb-md-0">
  176. <div class="btn-group me-2">
  177. <button type="button" class="btn btn-light" onclick="row1_show()" id="manageBtn">Manage</button>
  178. </div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. <div id="row3" style="background-color: #0f5132">
  184. <div class="collapse border-danger" id="moveItemsToCollapse">
  185. <div class="card card-body bg-dark text-white-50">
  186. <h5>Move or Copy videos to another playlist!</h5>
  187. <div class="d-flex justify-content-start">
  188. <input class="form-control w-50 bg-dark text-white border border-secondary" placeholder="Enter playlist ID here">
  189. <div class="btn-group ms-2">
  190. <button type="button" class="btn btn-info" id="select-all-btn">Move!</button>
  191. </div>
  192. <div class="btn-group ms-2">
  193. <button type="button" class="btn btn-info" id="select-all-btn">Copy!</button>
  194. </div>
  195. </div>
  196. <div class="d-flex justify-content-start mt-3">
  197. <div class="btn-group">
  198. <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>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. </div>
  204. <div id="row4" style="background-color: #0f5132">
  205. <div class="collapse border-danger" id="deleteItemsCollapse">
  206. <div class="card card-body bg-dark text-white-50">
  207. <div id="delete-videos-confirm-box">
  208. <h5>Are you sure you want to delete these 40 items from your YouTube playlist? This cannot be undone.</h5>
  209. </div>
  210. <div class="d-flex justify-content-start">
  211. <div class="btn-group ms-2">
  212. <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>
  213. </div>
  214. <div class="btn-group ms-2">
  215. <button type="button" class="btn btn-secondary" id="select-all-btn">Nvm</button>
  216. </div>
  217. <div class="btn-group ms-2">
  218. <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">
  219. <i class="fas fa-sync"></i>
  220. </button>
  221. </div>
  222. </div>
  223. </div>
  224. </div>
  225. </div>
  226. <div class="table-responsive" id="videos-div">
  227. <br>
  228. <div class="list-group" id="video-checkboxes">
  229. {% for video in videos %}
  230. <li class="list-group-item d-flex justify-content-between align-items-center bg-transparent" style="background-color: #40B3A2">
  231. {% if video.is_unavailable_on_yt and not video.was_deleted_on_yt %}
  232. <div class="d-flex justify-content-between align-items-center">
  233. <div>
  234. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ video.playlist_item_id }}" name="video-id">
  235. </div>
  236. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  237. <img src="https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg" class="img-fluid" alt="">
  238. </div>
  239. <div class="ms-4">
  240. <a class="link-dark" href="https://www.youtube.com/watch?v={{ video.video_id }}&list={{ video.playlist.playlist_id }}" target="_blank">
  241. {{ video.video_position }}. {{ video.name }}
  242. </a>
  243. <br><br>
  244. </div>
  245. </div>
  246. {% else %}
  247. <div class="d-flex justify-content-between align-items-center" >
  248. <div>
  249. <input class="video-checkboxes" style="display: none" type="checkbox" value="{{ video.playlist_item_id }}" name="video-id">
  250. </div>
  251. <div class="ms-4" style="max-width: 115px; max-height: 100px;">
  252. <img src="{% if video.thumbnail_url %}{{ video.thumbnail_url }}{% else %}https://i.ytimg.com/vi/9219YrnwDXE/maxresdefault.jpg{% endif %}" class="img-fluid" alt="">
  253. </div>
  254. <div class="ms-4">
  255. {{ video.video_position }}.
  256. <a class="link-dark" href="https://www.youtube.com/watch?v={{ video.videoid }}&list={{ video.playlist.playlist_id }}" target="_blank">
  257. {{ video.name|truncatewords:"16" }}
  258. </a> by {{ video.channel_name }} <br>
  259. <span class="badge bg-secondary">{{ video.duration }}</span>
  260. {% if video.has_cc %}<span class="badge bg-secondary">CC</span>{% endif %}
  261. {% if video.published_at %}<span class="badge bg-secondary">{{ video.published_at }}</span>{% endif %}
  262. {% if video.view_count %}<span class="badge bg-info">{{ video.view_count|intword|intcomma }} views</span>{% endif %}
  263. {% if video.is_duplicate %}<span class="badge bg-primary">duplicate</span>{% endif %}
  264. {% if video.is_unavailable_on_yt and video.was_deleted_on_yt %}<span class="badge bg-dark">UNAVAILABLE</span>{% endif %}
  265. {% 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>
  266. <br>
  267. </div>
  268. </div>
  269. <div class="ms-5">
  270. <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>
  271. <input class="form-control me-1 visually-hidden" id="video-{{ video.video_id }}" value="https://www.youtube.com/watch?v={{ video.video_id }}">
  272. <button class="copy-btn btn btn-sm btn-success mb-1" data-clipboard-target="#video-{{ video.video_id }}">
  273. <i class="far fa-copy" aria-hidden="true"></i>
  274. </button>
  275. <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>
  276. <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>
  277. <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">
  278. <div id="video-{{ forloop.counter }}-fav">
  279. {% if video.is_favorite %}
  280. <i class="fas fa-heart"></i>
  281. {% else %}
  282. <i class="far fa-heart"></i>
  283. {% endif %}
  284. </div>
  285. </button>
  286. {% if playlist.marked_as == "watching" %}
  287. <button class="btn btn-sm btn-light mb-1" type="button">
  288. <i class="far fa-check-circle"></i>
  289. </button>
  290. {% endif %}
  291. </div>
  292. {% endif %}
  293. </li>
  294. {% endfor %}
  295. {% endif %}
  296. </div>
  297. </div>
  298. </div>
  299. <!--
  300. <script src="{% static 'youtube-audio-player/iframe-api.js' %}"></script>
  301. <script src="{% static 'youtube-audio-player/yt.min.js' %}"></script>
  302. -->
  303. {% endblock %}