home.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. {% extends 'base.html' %}
  2. {% load humanize %}
  3. {% block content %}
  4. {% if user.playlists.all.count|add:"-1" <= -1 %}
  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_view_page' 'import' %}" class="btn btn-sm btn-primary">Import</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 'settings' %}" 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 'planned_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. {% if user.playlist_tags.all.count != 0 %}
  176. No playlist tag views this week.
  177. {% else %}
  178. You haven't created any playlist tags yet.
  179. {% endif %}
  180. {% endif %}
  181. </div>
  182. {% if playlist_tags %}
  183. <div class="d-flex justify-content-center">
  184. <h3>
  185. <a href="{% url 'search' %}" class="btn btn-success">Filter Playlists by Tags</a>
  186. </h3>
  187. </div>
  188. {% endif %}
  189. </div>
  190. </div>
  191. <br>
  192. {% if watching %}
  193. <div class="d-flex justify-content-between" id="continue-watching">
  194. <h3>
  195. <span style="border-bottom: 3px #e24949 dashed;">Continue Watching</span>
  196. <i class="fas fa-fire-alt ms-2" style="color: #d24646"></i>
  197. </h3>
  198. {% if watching.count > 5 %}
  199. <h3 class="ms-2 me-1">
  200. <a href="{% url 'library' 'watching' %}" style="text-decoration: none; color: #4675d2">
  201. <i class="fas fa-search" style="color: #4675d2"></i>
  202. </a>
  203. </h3>
  204. {% endif %}
  205. </div>
  206. <br>
  207. {% if watching.count > 4 %}
  208. <div class="container-fluid overflow-auto border border-5 rounded-3 border-primary p-3">
  209. <div class="row flex-row g-3 flex-nowrap">
  210. {% for playlist in watching %}
  211. <div class="col">
  212. <div class="card overflow-auto" style="background-color: #9363af; width: 275px; height: auto">
  213. <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">
  214. <div class="card-body">
  215. <h5 class="card-title"><a href="{% url 'playlist' playlist.playlist_id %}" class="stretched-link" style="text-decoration: none; color: black">{{ playlist.name }}</a></h5>
  216. <p class="card-text">
  217. <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>
  218. {% if playlist.get_watch_time_left != "0secs." %}<span class="badge bg-dark text-white">{{ playlist.get_watch_time_left }} left</span>{% endif %}
  219. </p>
  220. <!--
  221. <p class="card-text">
  222. {% if playlist.tags.all %}
  223. <small>
  224. <i class="fas fa-tags fa-sm" style="color: black"></i>
  225. {% for tag in playlist.tags.all %}
  226. <span class="badge rounded-pill bg-primary mb-lg-1">
  227. {{ tag.name }}
  228. </span>
  229. {% endfor %}
  230. </small>
  231. {% endif %}
  232. </p>
  233. -->
  234. <p class="card-text"><small class="text-muted">Last watched {{ playlist.last_watched|naturaltime }}</small></p>
  235. </div>
  236. </div>
  237. </div>
  238. {% endfor %}
  239. </div>
  240. </div>
  241. {% else %}
  242. <div class="container-fluid overflow-auto border border-5 rounded-3 border-primary pb-4">
  243. <div class="row row-cols-1 row-cols-md-4 g-4 text-dark mt-0">
  244. {% include 'intercooler/playlists.html' with playlists=watching watching=True %}
  245. </div>
  246. </div>
  247. {% endif %}
  248. <br>
  249. {% endif %}
  250. <br>
  251. <div class="row text-dark mt-0 d-flex justify-content-evenly" id="recent-playlists">
  252. <div class="col">
  253. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Added</span> <i class="fas fa-plus-square" style="color:#972727;"></i></h3>
  254. {% if recently_added_playlists %}
  255. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  256. {% include 'intercooler/playlists.html' with playlists=recently_added_playlists watching=False bg_color="#958a44" show_controls=False %}
  257. </div>
  258. {% else %}
  259. <br>
  260. <h5>You have no playlists ;-;</h5>
  261. {% endif %}
  262. </div>
  263. <div class="col">
  264. <h3><span style="border-bottom: 3px #e24949 dashed;">Recently Accessed</span> <i class="fas fa-redo fa-sm" style="color: #3c3fd2"></i></h3>
  265. {% if recently_accessed_playlists %}
  266. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  267. {% include 'intercooler/playlists.html' with playlists=recently_accessed_playlists watching=False bg_color="#9363af" show_controls=False %}
  268. </div>
  269. {% else %}
  270. <br>
  271. <h5>Nothing to see here... yet.</h5>
  272. {% endif %}
  273. </div>
  274. </div>
  275. <br>
  276. <br>
  277. <footer class="footer mt-auto py-3 bg-transparent">
  278. <div class="container d-flex justify-content-center">
  279. <span class="text-dark">Loved what I made?
  280. <a href="https://www.buymeacoffee.com/mohammedabkhan" style="text-decoration: none" target="_blank">
  281. <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>
  282. </a></span>
  283. </div>
  284. </footer>
  285. <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.3/dist/Chart.min.js"></script>
  286. <script type="application/javascript">
  287. $(function () {
  288. var $overallPlaylists = $("#overall-playlists-distribution");
  289. $.ajax({
  290. url: $overallPlaylists.data("url"),
  291. success: function (data) {
  292. var ctx = $overallPlaylists[0].getContext("2d");
  293. var coloR = [];
  294. var dynamicColors = function() { // generate random color
  295. var r = Math.floor(Math.random() * 255);
  296. var g = Math.floor(Math.random() * 255);
  297. var b = Math.floor(Math.random() * 255);
  298. return "rgb(" + r + "," + g + "," + b + ")";
  299. };
  300. for (var i in data.labels) {
  301. if (data.labels)
  302. coloR.push(dynamicColors());
  303. }
  304. new Chart(ctx, {
  305. type: 'pie',
  306. data: {
  307. labels: data.labels,
  308. datasets: [{
  309. label: 'Playlist Types',
  310. backgroundColor: coloR,
  311. data: data.data
  312. }]
  313. },
  314. options: {
  315. responsive: true,
  316. legend: {
  317. position: 'right',
  318. display: true
  319. },
  320. title: {
  321. display: false,
  322. text: 'Video Count Distribution per Channel',
  323. fontSize: 20,
  324. fontColor: '#fff',
  325. },
  326. tooltips: {
  327. callbacks: {
  328. label: function(tooltipItem, object) {
  329. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + ' playlists';
  330. }
  331. }
  332. }
  333. }
  334. });
  335. }
  336. });
  337. var $watchingPlaylists = $("#watching-playlists-percent-distribution");
  338. $.ajax({
  339. url: $watchingPlaylists.data("url"),
  340. success: function (data) {
  341. var ctx = $watchingPlaylists[0].getContext("2d");
  342. var coloR = [];
  343. var dynamicColors = function() { // generate random color
  344. var r = Math.floor(Math.random() * 255);
  345. var g = Math.floor(Math.random() * 255);
  346. var b = Math.floor(Math.random() * 255);
  347. return "rgb(" + r + "," + g + "," + b + ")";
  348. };
  349. for (var i in data.labels) {
  350. if (data.labels)
  351. coloR.push(dynamicColors());
  352. }
  353. new Chart(ctx, {
  354. type: 'polarArea',
  355. data: {
  356. labels: data.labels,
  357. datasets: [{
  358. label: 'Playlist Types',
  359. backgroundColor: coloR,
  360. data: data.data
  361. }]
  362. },
  363. options: {
  364. scale: {
  365. reverse: false,
  366. ticks: {
  367. min: -10,
  368. max: 100,
  369. interval: 10,
  370. }
  371. },
  372. responsive: true,
  373. legend: {
  374. position: 'right',
  375. display: {% if watching.count <= 10 %}true{% else %}false{% endif %},
  376. },
  377. title: {
  378. display: false,
  379. },
  380. tooltips: {
  381. callbacks: {
  382. label: function(tooltipItem, object) {
  383. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + '% complete';
  384. }
  385. }
  386. }
  387. }
  388. });
  389. }
  390. });
  391. var $overallChannels = $("#overall-channels-distribution");
  392. $.ajax({
  393. url: $overallChannels.data("url"),
  394. success: function (data) {
  395. var ctx = $overallChannels[0].getContext("2d");
  396. var coloR = [];
  397. var dynamicColors = function() { // generate random color
  398. var r = Math.floor(Math.random() * 255);
  399. var g = Math.floor(Math.random() * 255);
  400. var b = Math.floor(Math.random() * 255);
  401. return "rgb(" + r + "," + g + "," + b + ")";
  402. };
  403. for (var i in data.labels) {
  404. if (data.labels)
  405. coloR.push(dynamicColors());
  406. }
  407. new Chart(ctx, {
  408. type: 'pie',
  409. data: {
  410. labels: data.labels,
  411. datasets: [{
  412. label: 'Channel',
  413. backgroundColor: coloR,
  414. data: data.data
  415. }]
  416. },
  417. options: {
  418. responsive: true,
  419. legend: {
  420. position: 'right',
  421. display: false
  422. },
  423. title: {
  424. display: false,
  425. text: 'Video Count Distribution per Channel',
  426. fontSize: 20,
  427. fontColor: '#fff',
  428. },
  429. tooltips: {
  430. callbacks: {
  431. label: function(tooltipItem, object) {
  432. return object['labels'][tooltipItem['index']] + ": " + object['datasets'][0]['data'][tooltipItem['index']] + ' videos';
  433. }
  434. }
  435. }
  436. }
  437. });
  438. }
  439. });
  440. });
  441. </script>
  442. {% endif %}
  443. {% endblock %}