home.html 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. {% extends 'base.html' %}
  2. {% block content %}
  3. {% for message in messages %}
  4. <div class="alert alert-success alert-dismissible fade show" role="alert">
  5. {{ message }}
  6. <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
  7. </div>
  8. {% endfor %}
  9. {% if user.profile.just_joined %}
  10. {% if not channel_found %}
  11. <br>
  12. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  13. <h2>Uh-oh, we were not able to find any YouTube channel linked to this Google account. Please create a YouTube channel to be able to import/export playlists back and forth between YouTube and UnTube.</h2>
  14. </div>
  15. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  16. <a href="{% url 'home' %}" class="btn btn-lg btn-danger">Retry</a>
  17. </div>
  18. {% endif %}
  19. {% else %}
  20. {% if import_successful %}
  21. <br>
  22. <br>
  23. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  24. <h1>Welcome to UnTube, {{ user.username|capfirst }}</h1>
  25. </div>
  26. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  27. <h2>{{ user.profile.playlists.all.count }} playlists from YouTube have been successfully imported.</h2>
  28. </div>
  29. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  30. <h3>You'll now be able to import/export playlists from YouTube and UnTube :)</h3>
  31. </div>
  32. <div class="d-flex justify-content-center pt-3 pb-2 mb-3">
  33. <a href="{% url 'home' %}" class="btn btn-lg btn-success">Go to Dashboard</a>
  34. </div>
  35. {% else %}
  36. <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
  37. <h1 class="h2">Dashboard</h1>
  38. <!--
  39. <div class="btn-toolbar mb-2 mb-md-0">
  40. <div class="btn-group me-2">
  41. <button type="button" class="btn btn-sm btn-outline-secondary">Share</button>
  42. <button type="button" class="btn btn-sm btn-outline-secondary">Export</button>
  43. </div>
  44. <button type="button" class="btn btn-sm btn-outline-secondary dropdown-toggle">
  45. <span data-feather="calendar"></span>
  46. This week
  47. </button>
  48. </div>
  49. -->
  50. <span><small>Logged in as <b>{{ user.username }}</b></small></span>
  51. </div>
  52. {% if watching %}
  53. <div class="border border-5 rounded-3 border-primary p-3">
  54. <h3>Continue Watching</h3>
  55. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  56. {% for playlist in watching|slice:"0:2" %}
  57. <div class="col">
  58. <div class="card">
  59. <a style="background-color: #7e89c2;" href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item list-group-item-action" aria-current="true">
  60. <div class="card-body">
  61. <h5 class="card-title">
  62. {{ playlist.name }}
  63. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  64. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  65. </h5>
  66. <p class="card-text">
  67. {% if playlist.description %}
  68. {{ playlist.description }}
  69. {% else %}
  70. No description
  71. {% endif %}
  72. </p>
  73. <small>
  74. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} videos</span>
  75. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  76. <span class="badge bg-secondary rounded-pill">{{ playlist.num_of_accesses }} clicks </span>
  77. <span class="badge bg-info rounded-pill">2/23 viewed</span>
  78. </small>
  79. </div>
  80. </a>
  81. </div>
  82. </div>
  83. {% if forloop.counter == 2 %}
  84. {% if watching.count|add:"-2" != 0 %}
  85. <div class="col">
  86. <div class="card">
  87. <a style="background-color: #7e89c2;" href="{% url 'all_playlists' 'watching' %}" class="list-group-item list-group-item-action" aria-current="true">
  88. <div class="card-body">
  89. <p class="card-text">
  90. <h3>+ {{ watching.count|add:"-2" }} more</h3>
  91. </p>
  92. </div>
  93. </a>
  94. </div>
  95. </div>
  96. {% endif %}
  97. {% endif %}
  98. {% endfor %}
  99. </div>
  100. </div>
  101. {% endif %}
  102. <br>
  103. <h3>Most viewed playlists <a href="{% url 'all_playlists' 'all' %}" class="btn btn-sm btn-info">View All</a></h3>
  104. <div class="row row-cols-1 row-cols-md-3 g-4 text-dark mt-0">
  105. {% for playlist in user_playlists|slice:"0:3" %}
  106. <div class="col">
  107. <div class="card">
  108. <a style="background-color: #35795b;" href="{% url 'playlist' playlist.playlist_id %}" class="list-group-item list-group-item-action" aria-current="true">
  109. <div class="card-body">
  110. <h5 class="card-title">
  111. #{{ forloop.counter }} <br><br>{{ playlist.name }}
  112. {% if playlist.is_private_on_yt %}<small><span class="badge bg-light text-dark">Private</span></small> {% endif %}
  113. {% if playlist.is_from_yt %}<small><span class="badge bg-danger text-dark">YT</span></small> {% endif %}
  114. </h5>
  115. <p class="card-text">
  116. {% if playlist.description %}
  117. {{ playlist.description }}
  118. {% else %}
  119. No description
  120. {% endif %}
  121. </p>
  122. <small>
  123. <span class="badge bg-primary rounded-pill">{{ playlist.video_count }} videos</span>
  124. <span class="badge bg-primary rounded-pill">{{ playlist.playlist_duration }} </span>
  125. <span class="badge bg-secondary rounded-pill">{{ playlist.num_of_accesses }} clicks </span>
  126. </small>
  127. </div>
  128. </a>
  129. </div>
  130. </div>
  131. {% endfor %}
  132. </div>
  133. <br>
  134. <br>
  135. <h3>Recently Added</h3>
  136. <br>
  137. <h2>Add a playlist</h2>
  138. <br>
  139. <div class="table-responsive">
  140. <form class="form" role="form" method="post" action="{% url 'home' %}">
  141. {% csrf_token %}
  142. <label for="pl">Enter playlist id:<br></label>
  143. <input name="playlist-id" type="text" id="pl">
  144. <button type="submit" class="btn btn-info">Submit</button>
  145. <div class="spinner-border text-light" role="status">
  146. <span class="visually-hidden">Loading...</span>
  147. </div>
  148. <input class="form-check-input mx-3 big-checkbox" type="checkbox" value="a" name="s" id="checkbox"> <br>
  149. <input class="form-check-input mx-3 big-checkbox" type="checkbox" value="b" name="s" id="checkbox"> <br>
  150. <input class="form-check-input mx-3 big-checkbox" type="checkbox" value="c" name="s" id="checkbox"> <br>
  151. <input class="form-check-input mx-3 big-checkbox" type="checkbox" value="d" name="s" id="checkbox"> <br>
  152. </form>
  153. <br>
  154. <div class="list-group">
  155. <a href="https://www.youtube.com/playlist?list={{ playlist.playlist_id }}" class="list-group-item list-group-item-action active">
  156. <b>{{ playlist.name }}</b> by {{ playlist.channel_name }}
  157. <span class="badge badge-dark">{{ playlist.video_count }} videos</span>
  158. <span class="badge badge-dark">{{ playlist.playlist_duration }}</span>
  159. <span class="badge badge-dark">{% if playlist.has_unavailable_videos %}Some videos in the playlist are deleted{% endif %}</span>
  160. </a>
  161. {% for video in videos %}
  162. <a href="https://www.youtube.com/watch?v={{ video.video_id }}&list={{ video.playlist.playlist_id }}" class="list-group-item {% if not video.is_up %}list-group-item-dark{% else %}list-group-item-action{% endif %}">{{ video.video_position }}. {{ video.name }}</a>
  163. {% endfor %}
  164. </div>
  165. </div>
  166. {% endif %}
  167. {% endif %}
  168. {% endblock %}