home.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% block content %}
  4. {% if user.playlists.all.count == 0 %}
  5. <div class="alert alert-success" role="alert">
  6. <h4 class="alert-heading">It's empty in here</h4>
  7. <p>
  8. There's no playlists in your UnTube right now. You can change that by heading over to <a href="{% url 'manage_playlists' %}" class="btn btn-sm btn-primary">Manage</a> to import some public playlists into your UnTube.
  9. {% if not user.profile.imported_yt_playlists %}
  10. Or you could always head over to your <a href="{% url 'profile' %}" class="btn btn-sm btn-primary">Profile</a> to import all of your public/private YouTube playlists.
  11. {% else %}
  12. Keep in mind that your own YouTube playlists will automatically be imported into UnTube.
  13. {% endif %}
  14. </p>
  15. </div>
  16. {% endif %}
  17. {% if import_successful %}
  18. <br>
  19. <br>
  20. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  21. <h1>Welcome to UnTube, {{ user.username|capfirst }}</h1>
  22. </div>
  23. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  24. <h2>{{ user.playlists.all.count }} playlists from YouTube have been successfully imported.</h2>
  25. </div>
  26. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  27. <h3>You'll now be notified on the Dashboard whenever there's any new un-exported playlists on YouTube :)</h3>
  28. </div>
  29. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  30. <a href="{% url 'home' %}" class="btn btn-lg btn-success">Go to Dashboard</a>
  31. </div>
  32. {% else %}
  33. {% if user.profile.imported_yt_playlists %}
  34. <div hx-get="{% url 'user_playlists_updates' 'check-for-updates' %}" hx-trigger="load" hx-swap="outerHTML">
  35. </div>
  36. {% endif %}
  37. {% if watching %}
  38. <div class="border border-5 rounded-3 border-primary p-3">
  39. <h3><span style="border-bottom: 3px #e24949 dashed;">Continue Watching</span><i class="fas fa-fire-alt ms-2" style="color: #d24646"></i></h3>
  40. <div class="row row-cols-1 row-cols-md-4 g-4 text-dark mt-0" data-masonry='{"percentPosition": true }'>
  41. {% for playlist in watching %}
  42. <div class="col">
  43. <div class="card" style="background-color: #EFEFEF;">
  44. <img class="bd-placeholder-img card-img-top" src="{{ playlist.thumbnail_url }}" style="max-width:100%; height: 200px; object-fit: cover;" alt="{{ playlist.name }} thumbnail">
  45. <div class="card-body">
  46. <h5 class="card-title"><a href="{% url 'playlist' playlist.playlist_id %}" class="stretched-link" style="text-decoration: none; color: black">{{ playlist.name }}</a></h5>
  47. <p class="card-text">
  48. <span class="badge bg-{% if playlist.get_watch_time_left == "0secs." %}success{% else %}primary{% endif %} text-white">{{ playlist.get_watched_videos_count }}/{{ playlist.get_watchable_videos_count }} viewed</span>
  49. {% if playlist.get_watch_time_left != "0secs." %}<span class="badge bg-dark text-white">{{ playlist.get_watch_time_left }} left</span>{% endif %}
  50. </p>
  51. <p class="card-text">
  52. {% if playlist.tags.all %}
  53. <small>
  54. <i class="fas fa-tags fa-sm" style="color: black"></i>
  55. {% for tag in playlist.tags.all %}
  56. <span class="badge rounded-pill bg-primary mb-lg-1">
  57. {{ tag.name }}
  58. </span>
  59. {% endfor %}
  60. </small>
  61. {% endif %}
  62. </p>
  63. <p class="card-text"><small class="text-muted">Last watched {{ playlist.last_watched|naturalday }}</small></p>
  64. </div>
  65. </div>
  66. </div>
  67. <!--
  68. <div class="col">
  69. <div class="card">
  70. <a style="background-color: #7e89c2;" href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item list-group-item-action" aria-current="true">
  71. <div class="card-body">
  72. <h5 class="card-title">
  73. {{ playlist.name }}
  74. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  75. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  76. </h5>
  77. <p class="card-text">
  78. <span class="badge bg-{% if playlist.get_watch_time_left == "0secs." %}success{% else %}primary{% endif %} text-white">{{ playlist.get_watched_videos_count }}/{{ playlist.get_watchable_videos_count }} viewed</span>
  79. {% if playlist.get_watch_time_left != "0secs." %}<span class="badge bg-dark text-white">{{ playlist.get_watch_time_left }} left</span>{% endif %}
  80. </p>
  81. {% if playlist.tags.all %}
  82. <small>
  83. <i class="fas fa-tags fa-sm" style="color: yellow"></i>
  84. {% for tag in playlist.tags.all %}
  85. <span class="badge rounded-pill bg-primary mb-lg-1">
  86. {{ tag.name }}
  87. </span>
  88. {% endfor %}
  89. </small>
  90. {% endif %}
  91. </div>
  92. </a>
  93. </div>
  94. </div> -->
  95. <!--
  96. {% if forloop.counter == 3 %}
  97. {% if watching.count|add:"-3" != 0 %}
  98. <div class="col">
  99. <div class="card">
  100. <a style="background-color: #7e89c2;" href="{% url 'all_playlists' 'watching' %}" class="list-group-item list-group-item-action" aria-current="true">
  101. <div class="card-body">
  102. <p class="card-text">
  103. <h3>+ {{ watching.count|add:"-3" }} more</h3>
  104. </p>
  105. </div>
  106. </a>
  107. </div>
  108. </div>
  109. {% endif %}
  110. {% endif %}
  111. -->
  112. {% endfor %}
  113. </div>
  114. </div>
  115. <br>
  116. {% endif %}
  117. <div class="row" ><!--data-masonry='{"percentPosition": true }'-->
  118. {% for playlist in user_playlists|slice:"0:3" %}
  119. <div class="col-sm-6 col-lg-4 mb-4">
  120. <div class="card card-cover h-100 overflow-hidden text-white bg-dark rounded-5 shadow-lg" style="">
  121. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  122. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold"><a href="{% url 'playlist' playlist.playlist_id %}" class="stretched-link" style="text-decoration: none; color: #fafafa">{{ playlist.name }}</a> </h2>
  123. <ul class="d-flex list-unstyled mt-auto">
  124. <li class="me-auto">
  125. <img src="{{ playlist.thumbnail_url }}" alt="Bootstrap" width="32" height="32" class="rounded-circle border border-white">
  126. </li>
  127. <li class="d-flex align-items-center me-3">
  128. <small>by {{ playlist.channel_name }}</small>
  129. </li>
  130. <li class="d-flex align-items-center">
  131. <i class="fas fa-eye me-1"></i>
  132. <small>{{ playlist.num_of_accesses }} clicks</small>
  133. </li>
  134. </ul>
  135. </div>
  136. </div>
  137. </div>
  138. {% endfor %}
  139. <div class="col-sm-6 col-lg-4 mb-4">
  140. <div class="card">
  141. <svg class="bd-placeholder-img card-img-top" width="100%" height="200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Image cap" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"/><text x="50%" y="50%" fill="#dee2e6" dy=".3em">Image cap</text></svg>
  142. <div class="card-body">
  143. <h5 class="card-title">Card title that wraps to a new line</h5>
  144. <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
  145. </div>
  146. </div>
  147. </div>
  148. <div class="col-sm-6 col-lg-4 mb-4">
  149. <div class="card bg-dark text-white">
  150. <div class="card-body">
  151. <h6 class="d-flex align-items-center mb-3"><span class="text-info me-2">{{ user.playlists.count }}</span>Playlists Statistics</h6>
  152. <div class="d-flex align-items-center mb-3">
  153. <canvas id="overall-playlists-distribution" data-url="{% url 'overall_playlists_distribution' %}">
  154. </canvas>
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. <div class="col-sm-6 col-lg-4 mb-4">
  160. <div class="card">
  161. <svg class="bd-placeholder-img card-img-top" width="100%" height="200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Image cap" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"/><text x="50%" y="50%" fill="#dee2e6" dy=".3em">Image cap</text></svg>
  162. <div class="card-body">
  163. <h5 class="card-title">Card title</h5>
  164. <p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
  165. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  166. </div>
  167. </div>
  168. </div>
  169. <div class="col-sm-6 col-lg-4 mb-4">
  170. <div class="card p-3">
  171. <figure class="p-3 mb-0">
  172. <blockquote class="blockquote">
  173. <p>A well-known quote, contained in a blockquote element.</p>
  174. </blockquote>
  175. <figcaption class="blockquote-footer mb-0 text-muted">
  176. Someone famous in <cite title="Source Title">Source Title</cite>
  177. </figcaption>
  178. </figure>
  179. </div>
  180. </div>
  181. <div class="col-sm-6 col-lg-4 mb-4">
  182. <div class="card text-center">
  183. <div class="card-body">
  184. <h5 class="card-title">Card title</h5>
  185. <p class="card-text">This card has a regular title and short paragraph of text below it.</p>
  186. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  187. </div>
  188. </div>
  189. </div>
  190. <div class="col-sm-6 col-lg-4 mb-4">
  191. <div class="card">
  192. <svg class="bd-placeholder-img card-img" width="100%" height="260" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Placeholder: Card image" preserveAspectRatio="xMidYMid slice" focusable="false"><title>Placeholder</title><rect width="100%" height="100%" fill="#868e96"/><text x="50%" y="50%" fill="#dee2e6" dy=".3em">Card image</text></svg>
  193. </div>
  194. </div>
  195. <div class="col-sm-6 col-lg-4 mb-4">
  196. <div class="card p-3 text-end">
  197. <figure class="mb-0">
  198. <blockquote class="blockquote">
  199. <p>A well-known quote, contained in a blockquote element.</p>
  200. </blockquote>
  201. <figcaption class="blockquote-footer mb-0 text-muted">
  202. Someone famous in <cite title="Source Title">Source Title</cite>
  203. </figcaption>
  204. </figure>
  205. </div>
  206. </div>
  207. <div class="col-sm-6 col-lg-4 mb-4">
  208. <div class="card">
  209. <div class="card-body">
  210. <h5 class="card-title">Card title</h5>
  211. <p class="card-text">This is another card with title and supporting text below. This card has some additional content to make it slightly taller overall.</p>
  212. <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
  213. </div>
  214. </div>
  215. </div>
  216. </div>
  217. <div class="container" id="custom-cards">
  218. <h2 class="pb-2 border-bottom">Custom cards</h2>
  219. <div class="row row-cols-1 row-cols-lg-3 align-items-stretch g-4 py-5">
  220. {% for playlist in user_playlists|slice:"0:3" %}
  221. <div class="col">
  222. <div class="card card-cover h-100 overflow-hidden text-dark bg-dark rounded-5 shadow-lg" style="background-image: url('{% if playlist.videos.count != 0 %}{{ playlist.thumbnail_url }}{% endif %}'); background-position: center">
  223. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  224. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold"><a href="{% url 'playlist' playlist.playlist_id %}" class="stretched-link" style="text-decoration: none; color: #100f0f">{{ playlist.name }}</a> </h2>
  225. <ul class="d-flex list-unstyled mt-auto">
  226. <li class="me-auto">
  227. <img src="{{ playlist.thumbnail_url }}" alt="Bootstrap" width="32" height="32" class="rounded-circle border border-white">
  228. </li>
  229. <li class="d-flex align-items-center me-3 text-dark">
  230. <small>by {{ playlist.channel_name }}</small>
  231. </li>
  232. <li class="d-flex align-items-center text-dark">
  233. <i class="fas fa-eye me-1"></i>
  234. <small>{{ playlist.num_of_accesses }}</small>
  235. </li>
  236. </ul>
  237. </div>
  238. </div>
  239. </div>
  240. {% endfor %}
  241. </div>
  242. </div>
  243. <div class="row text-dark mt-0 align-items-center">
  244. <div class="col">
  245. <div class="row">
  246. <div class="col">
  247. <div class="card" style="background: linear-gradient(-45deg, #aaae6b, #7b8eab, #8abc97, #e666f5); background-size: 400% 400%; animation: gradient 7s ease infinite;">
  248. <a href="#" class="list-group-item bg-transparent list-group-item-action" aria-current="true">
  249. <div class="card-body">
  250. <div class="d-flex justify-content-center h1">
  251. <i class="fas fa-map-pin" style="color:#c22929"></i>
  252. </div>
  253. <div class="d-flex justify-content-center h1">
  254. YOUR
  255. </div>
  256. <div class="d-flex justify-content-center h1">
  257. PINS
  258. </div>
  259. </div>
  260. </a>
  261. </div>
  262. </div>
  263. <div class="col">
  264. <div class="card" style="background: linear-gradient(-45deg, #0645a4, #2480cd, #84bcf3, #b7d6f7); background-size: 400% 400%; animation: gradient 7s ease infinite;">
  265. <a href="#" class="list-group-item list-group-item-action bg-transparent" aria-current="true">
  266. <div class="card-body">
  267. <div class="d-flex justify-content-center h1">
  268. <i class="fas fa-heart" style="color: indianred"></i>
  269. </div>
  270. <div class="d-flex justify-content-center h1">
  271. LIKED
  272. </div>
  273. <div class="d-flex justify-content-center h1">
  274. VIDEOS
  275. </div>
  276. </div>
  277. </a>
  278. </div>
  279. </div>
  280. </div>
  281. <!-- Implement later
  282. <div class="row mt-3">
  283. <div class="col">
  284. </div>
  285. <div class="col-6">
  286. <div class="card">
  287. <a style="background: linear-gradient(-45deg, #e2b968, #68af5b, #8a97bc, #d69ab2); background-size: 400% 400%; animation: gradient 7s ease infinite;" href="#" class="list-group-item list-group-item-action" aria-current="true">
  288. <div class="card-body">
  289. <div class="d-flex justify-content-center h1">
  290. <i class="fas fa-history"></i>
  291. </div>
  292. <div class="d-flex justify-content-center h1">
  293. YOUR
  294. </div>
  295. <div class="d-flex justify-content-center h1">
  296. ACTIVITY
  297. </div>
  298. </div>
  299. </a>
  300. </div>
  301. </div>
  302. <div class="col">
  303. </div>
  304. </div>
  305. -->
  306. </div>
  307. <div class="col-8">
  308. <!--
  309. <div class="card bg-transparent text-black border border-5 rounded-3 border-success p-3">
  310. <div class="card-body">
  311. <h3><span style="border-bottom: 3px #e24949 dashed;">Most viewed playlists</span> <a href="{% url 'all_playlists' 'all' %}" class="pt-1"><i class="fas fa-binoculars"></i> </a></h3>
  312. {% if user_playlists %}
  313. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  314. {% for playlist in user_playlists|slice:"0:3" %}
  315. <div class="col">
  316. <div class="card overflow-auto" style="background-color: #4790c7;">
  317. <a href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item bg-transparent list-group-item-action" aria-current="true">
  318. <div class="card-body">
  319. <h5 class="card-title">
  320. #{{ forloop.counter }} <br><br>{{ playlist.name }}
  321. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  322. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  323. </h5>
  324. <small>
  325. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} videos</span>
  326. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  327. <span class="badge bg-secondary rounded-pill">{{ playlist.num_of_accesses }} clicks </span>
  328. </small>
  329. </div>
  330. </a>
  331. </div>
  332. </div>
  333. {% endfor %}
  334. </div>
  335. {% else %}
  336. <br>
  337. <h5>Nothing to see here... yet.</h5>
  338. {% endif %}
  339. </div>
  340. </div>
  341. -->
  342. </div>
  343. </div>
  344. <br>
  345. <div class="row text-dark mt-0 d-flex justify-content-evenly">
  346. <div class="col">
  347. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Added</span> <i class="fas fa-plus-square" style="color:#972727;"></i></h3>
  348. {% if recently_added_playlists %}
  349. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  350. {% for playlist in recently_added_playlists %}
  351. <div class="col">
  352. <div class="card overflow-auto" style="background-color: #958a44;">
  353. <a href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item bg-transparent list-group-item-action" aria-current="true">
  354. <div class="card-body">
  355. <h5 class="card-title">
  356. {{ playlist.name }}
  357. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  358. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  359. </h5>
  360. <small>
  361. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} videos</span>
  362. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  363. <span class="badge bg-secondary rounded-pill">{{ playlist.num_of_accesses }} clicks </span>
  364. </small>
  365. </div>
  366. </a>
  367. </div>
  368. </div>
  369. {% endfor %}
  370. </div>
  371. {% else %}
  372. <br>
  373. <h5>You have no playlists ;-;</h5>
  374. {% endif %}
  375. </div>
  376. <div class="col">
  377. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Accessed</span> <i class="fas fa-redo fa-sm" style="color: #3c3fd2"></i></h3>
  378. {% if recently_accessed_playlists %}
  379. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  380. {% for playlist in recently_accessed_playlists %}
  381. <div class="col">
  382. <div class="card overflow-auto" style="background-color: #357779;">
  383. <a href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item bg-transparent list-group-item-action" aria-current="true">
  384. <div class="card-body">
  385. <h5 class="card-title">
  386. {{ playlist.name }}
  387. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  388. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  389. </h5>
  390. <small>
  391. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} videos</span>
  392. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  393. <span class="badge bg-secondary rounded-pill">{{ playlist.num_of_accesses }} clicks </span>
  394. </small>
  395. </div>
  396. </a>
  397. </div>
  398. </div>
  399. {% endfor %}
  400. </div>
  401. {% else %}
  402. <br>
  403. <h5>Nothing to see here... yet.</h5>
  404. {% endif %}
  405. </div>
  406. </div>
  407. <br>
  408. <br>
  409. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  410. <script type="application/javascript">
  411. $(function () {
  412. var $populationChart = $("#overall-playlists-distribution");
  413. $.ajax({
  414. url: $populationChart.data("url"),
  415. success: function (data) {
  416. var ctx = $populationChart[0].getContext("2d");
  417. var coloR = [];
  418. var dynamicColors = function() { // generate random color
  419. var r = Math.floor(Math.random() * 255);
  420. var g = Math.floor(Math.random() * 255);
  421. var b = Math.floor(Math.random() * 255);
  422. return "rgb(" + r + "," + g + "," + b + ")";
  423. };
  424. for (var i in data.labels) {
  425. if (data.labels)
  426. coloR.push(dynamicColors());
  427. }
  428. new Chart(ctx, {
  429. type: 'pie',
  430. data: {
  431. labels: data.labels,
  432. datasets: [{
  433. label: 'Playlist Types',
  434. backgroundColor: coloR,
  435. data: data.data
  436. }]
  437. },
  438. options: {
  439. responsive: true,
  440. legend: {
  441. position: 'right',
  442. display: true
  443. },
  444. title: {
  445. display: false,
  446. text: 'Video Count Distribution per Channel',
  447. fontSize: 20,
  448. fontColor: '#fff',
  449. },
  450. }
  451. });
  452. }
  453. });
  454. });
  455. </script>
  456. {% endif %}
  457. {% endblock %}