home.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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>{{ imported_playlists_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. <div class="row">
  38. <div class="col-6 mb-4">
  39. <div class="card bg-transparent text-dark">
  40. <div class="card-body">
  41. <h6 class="d-flex justify-content-center align-items-center mb-3">You have a total of <span class="text-warning ms-1 me-1">{{ user.playlists.count }}</span> Playlists in your UnTube collection</h6>
  42. <div class="d-flex align-items-center mb-3">
  43. <canvas id="overall-playlists-distribution" data-url="{% url 'overall_playlists_distribution' %}">
  44. </canvas>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. <div class="col-6 mb-4">
  50. <div class="card bg-transparent text-dark">
  51. <div class="card-body">
  52. <h6 class="d-flex justify-content-center align-items-center mb-3">A total of <span class="text-warning me-1 ms-1" id="num-channels">{{ channels.count|intword|intcomma }} channels</span> and <span class="text-warning ms-1 me-1" id="num-channels"> {{ videos.count|intword|intcomma }} videos</span> found in your UnTube collection </h6>
  53. {% if channels.count > 100 %}<h6 class="d-flex justify-content-center">(Only top 100 channels shown below)</h6>{% endif %}
  54. <div class="d-flex align-items-center mb-3">
  55. <canvas id="overall-channels-distribution" data-url="{% url 'overall_channels_distribution' %}">
  56. </canvas>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="row row-cols-1 row-cols-md-4 g-4"><!--data-masonry='{"percentPosition": true }'-->
  63. <div class="col mb-4">
  64. <div class="card card-cover h-100 overflow-hidden text-white {% if not user.profile.enable_gradient_bg %}gradient-bg-3{% else %}bg-dark{% endif %} rounded-5 shadow-lg" style="">
  65. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  66. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold">
  67. <a href="{% url 'library' 'all' %}" class="stretched-link" style="text-decoration: none; color: #fafafa">
  68. All Playlists</a>
  69. </h2>
  70. <ul class="d-flex list-unstyled mt-auto">
  71. <li class="me-auto">
  72. <h3>
  73. <i class="fas fa-mountain fa-lg" style="color: #a9e26f"></i>
  74. </h3>
  75. </li>
  76. </ul>
  77. </div>
  78. </div>
  79. </div>
  80. <div class="col mb-4">
  81. <div class="card card-cover h-100 overflow-hidden text-white {% if not user.profile.enable_gradient_bg %}gradient-bg-3{% else %}bg-dark{% endif %} rounded-5 shadow-lg" style="">
  82. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  83. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold">
  84. <a href="{% url 'playlist' 'LL' %}" class="stretched-link" style="text-decoration: none; color: #fafafa">
  85. Liked Videos
  86. </a>
  87. </h2>
  88. <ul class="d-flex list-unstyled mt-auto">
  89. <li class="me-auto">
  90. <h3>
  91. <i class="fas fa-thumbs-up fa-lg" style="color: #0090ff"></i>
  92. </h3>
  93. </li>
  94. </ul>
  95. </div>
  96. </div>
  97. </div>
  98. <div class="col mb-4">
  99. <div class="card card-cover h-100 overflow-hidden text-white {% if not user.profile.enable_gradient_bg %}gradient-bg-3{% else %}bg-dark{% endif %} rounded-5 shadow-lg" style="">
  100. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  101. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold">
  102. <a href="{% url 'favorites' %}" class="stretched-link" style="text-decoration: none; color: #fafafa">
  103. Your Favorites
  104. </a>
  105. </h2>
  106. <ul class="d-flex list-unstyled mt-auto">
  107. <li class="me-auto">
  108. <h3>
  109. <i class="fas fa-star fa-lg" style="color: #dbcc47"></i>
  110. </h3>
  111. </li>
  112. </ul>
  113. </div>
  114. </div>
  115. </div>
  116. <div class="col mb-4">
  117. <div class="card card-cover h-100 overflow-hidden text-white {% if not user.profile.enable_gradient_bg %}gradient-bg-3{% else %}bg-dark{% endif %} rounded-5 shadow-lg" style="">
  118. <div class="d-flex flex-column h-100 p-5 pb-3 text-white text-shadow-1">
  119. <h2 class="pt-5 mt-5 mb-4 display-6 lh-1 fw-bold">
  120. <a href="{% url 'library' 'plan-to-watch' %}" class="stretched-link" style="text-decoration: none; color: #fafafa">
  121. Planned to Watch
  122. </a>
  123. </h2>
  124. <ul class="d-flex list-unstyled mt-auto">
  125. <li class="me-auto">
  126. <h3>
  127. <i class="fas fa-sad-cry fa-lg" style="color: #db477b"></i>
  128. </h3>
  129. </li>
  130. </ul>
  131. </div>
  132. </div>
  133. </div>
  134. <!-- FULL IMAGE CARD: might be useful
  135. <div class="col-sm-6 col-lg-4 mb-4">
  136. <div class="card">
  137. <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>
  138. </div>
  139. </div>
  140. -->
  141. </div>
  142. <br>
  143. <div class="row text-dark mt-0 align-items-center">
  144. <div class="col">
  145. <div class="card bg-transparent text-dark">
  146. <div class="card-body">
  147. <h6 class="d-flex justify-content-center align-items-center mb-3"><span class="text-warning me-2">{{ watching.count }}</span>
  148. {% if watching.count > 0 %}
  149. Playlist{% if watching.count > 1 %}s{% endif %} Watching: Percent Complete Chart
  150. {% else %}
  151. Watching: Mark playlists as watching to view their completeness % here!
  152. {% endif %}
  153. </h6>
  154. <div class="d-flex align-items-center mb-3">
  155. <canvas id="watching-playlists-percent-distribution" data-url="{% url 'watching_playlists_percent_distribution' %}">
  156. </canvas>
  157. </div>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="col">
  162. <div class="d-flex justify-content-center">
  163. <h2>Popular Playlist Tags</h2>
  164. </div>
  165. <div class="d-flex justify-content-evenly h4">
  166. {% if playlist_tags %}
  167. <div class="w-100 d-flex justify-content-center flex-wrap">
  168. {% for tag in playlist_tags|slice:"0:19" %}
  169. <a href="{% url 'tagged_playlists' tag.name %}" style="text-decoration: none" class="me-lg-1 mb-lg-1">
  170. <span class="badge rounded-pill bg-warning bg-gradient text-black-50">{{ tag.name }} <span class="badge bg-dark text-white">{{ tag.times_viewed_per_week }} views</span></span>
  171. </a>
  172. {% endfor %}
  173. </div>
  174. {% else %}
  175. You haven't created any playlist tags yet.
  176. {% endif %}
  177. </div>
  178. {% if playlist_tags %}
  179. <div class="d-flex justify-content-center">
  180. <h3>
  181. <a href="{% url 'search' %}" class="btn btn-success">Filter Playlists by Tags</a>
  182. </h3>
  183. </div>
  184. {% endif %}
  185. </div>
  186. </div>
  187. <br>
  188. {% if watching %}
  189. <div class="d-flex justify-content-between" id="continue-watching">
  190. <h3>
  191. <span style="border-bottom: 3px #e24949 dashed;">Continue Watching</span>
  192. <i class="fas fa-fire-alt ms-2" style="color: #d24646"></i>
  193. </h3>
  194. {% if watching.count > 5 %}
  195. <h3 class="ms-2 me-1">
  196. <a href="{% url 'library' 'watching' %}" style="text-decoration: none; color: #4675d2">
  197. <i class="fas fa-search" style="color: #4675d2"></i>
  198. </a>
  199. </h3>
  200. {% endif %}
  201. </div>
  202. <br>
  203. {% if watching.count > 4 %}
  204. <div class="container-fluid overflow-auto border border-5 rounded-3 border-primary p-3">
  205. <div class="row flex-row g-3 flex-nowrap">
  206. {% for playlist in watching %}
  207. <div class="col">
  208. <div class="card overflow-auto" style="background-color: #9363af; width: 275px; height: auto">
  209. <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">
  210. <div class="card-body">
  211. <h5 class="card-title"><a href="{% url 'playlist' playlist.playlist_id %}" class="stretched-link" style="text-decoration: none; color: black">{{ playlist.name }}</a></h5>
  212. <p class="card-text">
  213. <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>
  214. {% if playlist.get_watch_time_left != "0secs." %}<span class="badge bg-dark text-white">{{ playlist.get_watch_time_left }} left</span>{% endif %}
  215. </p>
  216. <!--
  217. <p class="card-text">
  218. {% if playlist.tags.all %}
  219. <small>
  220. <i class="fas fa-tags fa-sm" style="color: black"></i>
  221. {% for tag in playlist.tags.all %}
  222. <span class="badge rounded-pill bg-primary mb-lg-1">
  223. {{ tag.name }}
  224. </span>
  225. {% endfor %}
  226. </small>
  227. {% endif %}
  228. </p>
  229. -->
  230. <p class="card-text"><small class="text-muted">Last watched {{ playlist.last_watched|naturaltime }}</small></p>
  231. </div>
  232. </div>
  233. </div>
  234. {% endfor %}
  235. </div>
  236. </div>
  237. {% else %}
  238. <div class="container-fluid overflow-auto border border-5 rounded-3 border-primary pb-4">
  239. <div class="row row-cols-1 row-cols-md-4 g-4 text-dark mt-0">
  240. {% include 'intercooler/playlists.html' with playlists=watching watching=True %}
  241. </div>
  242. </div>
  243. {% endif %}
  244. <br>
  245. {% endif %}
  246. <br>
  247. <div class="row text-dark mt-0 d-flex justify-content-evenly" id="recent-playlists">
  248. <div class="col">
  249. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Added</span> <i class="fas fa-plus-square" style="color:#972727;"></i></h3>
  250. {% if recently_added_playlists %}
  251. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  252. {% include 'intercooler/playlists.html' with playlists=recently_added_playlists watching=False bg_color="#958a44" show_controls=False %}
  253. </div>
  254. {% else %}
  255. <br>
  256. <h5>You have no playlists ;-;</h5>
  257. {% endif %}
  258. </div>
  259. <div class="col">
  260. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Accessed</span> <i class="fas fa-redo fa-sm" style="color: #3c3fd2"></i></h3>
  261. {% if recently_accessed_playlists %}
  262. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  263. {% include 'intercooler/playlists.html' with playlists=recently_accessed_playlists watching=False bg_color="#9363af" show_controls=False %}
  264. </div>
  265. {% else %}
  266. <br>
  267. <h5>Nothing to see here... yet.</h5>
  268. {% endif %}
  269. </div>
  270. </div>
  271. <br>
  272. <br>
  273. <footer class="footer mt-auto py-3 bg-transparent">
  274. <div class="container d-flex justify-content-center">
  275. <span class="text-dark">Loved what I made?
  276. <a href="https://www.buymeacoffee.com/mohammedabkhan" style="text-decoration: none" target="_blank">
  277. <span style="border-bottom: 3px #d56b6b dashed;">You can support me by buying me some coffee </span><i class="far fa-smile" style="color: black"></i>
  278. </a></span>
  279. </div>
  280. </footer>
  281. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  282. <script type="application/javascript">
  283. $(function () {
  284. var $overallPlaylists = $("#overall-playlists-distribution");
  285. $.ajax({
  286. url: $overallPlaylists.data("url"),
  287. success: function (data) {
  288. var ctx = $overallPlaylists[0].getContext("2d");
  289. var coloR = [];
  290. var dynamicColors = function() { // generate random color
  291. var r = Math.floor(Math.random() * 255);
  292. var g = Math.floor(Math.random() * 255);
  293. var b = Math.floor(Math.random() * 255);
  294. return "rgb(" + r + "," + g + "," + b + ")";
  295. };
  296. for (var i in data.labels) {
  297. if (data.labels)
  298. coloR.push(dynamicColors());
  299. }
  300. new Chart(ctx, {
  301. type: 'pie',
  302. data: {
  303. labels: data.labels,
  304. datasets: [{
  305. label: 'Playlist Types',
  306. backgroundColor: coloR,
  307. data: data.data
  308. }]
  309. },
  310. options: {
  311. responsive: true,
  312. legend: {
  313. position: 'right',
  314. display: true
  315. },
  316. title: {
  317. display: false,
  318. text: 'Video Count Distribution per Channel',
  319. fontSize: 20,
  320. fontColor: '#fff',
  321. },
  322. tooltips: {
  323. callbacks: {
  324. label: function(tooltipItem, object) {
  325. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + ' playlists';
  326. }
  327. }
  328. }
  329. }
  330. });
  331. }
  332. });
  333. var $watchingPlaylists = $("#watching-playlists-percent-distribution");
  334. $.ajax({
  335. url: $watchingPlaylists.data("url"),
  336. success: function (data) {
  337. var ctx = $watchingPlaylists[0].getContext("2d");
  338. var coloR = [];
  339. var dynamicColors = function() { // generate random color
  340. var r = Math.floor(Math.random() * 255);
  341. var g = Math.floor(Math.random() * 255);
  342. var b = Math.floor(Math.random() * 255);
  343. return "rgb(" + r + "," + g + "," + b + ")";
  344. };
  345. for (var i in data.labels) {
  346. if (data.labels)
  347. coloR.push(dynamicColors());
  348. }
  349. new Chart(ctx, {
  350. type: 'polarArea',
  351. data: {
  352. labels: data.labels,
  353. datasets: [{
  354. label: 'Playlist Types',
  355. backgroundColor: coloR,
  356. data: data.data
  357. }]
  358. },
  359. options: {
  360. scale: {
  361. reverse: false,
  362. ticks: {
  363. min: -10,
  364. max: 100,
  365. interval: 10,
  366. }
  367. },
  368. responsive: true,
  369. legend: {
  370. position: 'right',
  371. display: {% if watching.count <= 10 %}true{% else %}false{% endif %},
  372. },
  373. title: {
  374. display: false,
  375. },
  376. tooltips: {
  377. callbacks: {
  378. label: function(tooltipItem, object) {
  379. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + '% complete';
  380. }
  381. }
  382. }
  383. }
  384. });
  385. }
  386. });
  387. var $overallChannels = $("#overall-channels-distribution");
  388. $.ajax({
  389. url: $overallChannels.data("url"),
  390. success: function (data) {
  391. var ctx = $overallChannels[0].getContext("2d");
  392. var coloR = [];
  393. var dynamicColors = function() { // generate random color
  394. var r = Math.floor(Math.random() * 255);
  395. var g = Math.floor(Math.random() * 255);
  396. var b = Math.floor(Math.random() * 255);
  397. return "rgb(" + r + "," + g + "," + b + ")";
  398. };
  399. for (var i in data.labels) {
  400. if (data.labels)
  401. coloR.push(dynamicColors());
  402. }
  403. new Chart(ctx, {
  404. type: 'pie',
  405. data: {
  406. labels: data.labels,
  407. datasets: [{
  408. label: 'Channel',
  409. backgroundColor: coloR,
  410. data: data.data
  411. }]
  412. },
  413. options: {
  414. responsive: true,
  415. legend: {
  416. position: 'right',
  417. display: false
  418. },
  419. title: {
  420. display: false,
  421. text: 'Video Count Distribution per Channel',
  422. fontSize: 20,
  423. fontColor: '#fff',
  424. },
  425. tooltips: {
  426. callbacks: {
  427. label: function(tooltipItem, object) {
  428. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + ' videos';
  429. }
  430. }
  431. }
  432. }
  433. });
  434. }
  435. });
  436. });
  437. </script>
  438. {% endif %}
  439. {% endblock %}