home.html 25 KB

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