diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f20c1a0..3bf201c 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -2,9 +2,19 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -68,32 +78,32 @@
-
-
+
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
@@ -102,131 +112,75 @@
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
+
+
+
+
@@ -439,19 +393,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -477,26 +418,7 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
@@ -514,7 +436,7 @@
-
+
@@ -674,12 +596,12 @@
-
+
-
+
@@ -696,7 +618,7 @@
-
+
@@ -731,32 +653,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -792,17 +688,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -860,16 +745,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -945,34 +820,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -1025,13 +872,6 @@
-
-
-
-
-
-
-
@@ -1039,9 +879,6 @@
-
-
-
@@ -1064,17 +901,14 @@
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
@@ -1088,13 +922,54 @@
-
+
-
-
+
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -1106,22 +981,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -1141,5 +1002,82 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/YtManager/settings.py b/YtManager/settings.py
index 5256f75..3f6851a 100644
--- a/YtManager/settings.py
+++ b/YtManager/settings.py
@@ -41,6 +41,7 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
+ 'django.contrib.humanize'
]
MIDDLEWARE = [
diff --git a/YtManagerApp/management/jobs/synchronize.py b/YtManagerApp/management/jobs/synchronize.py
index 8c1f60f..bbc5d97 100644
--- a/YtManagerApp/management/jobs/synchronize.py
+++ b/YtManagerApp/management/jobs/synchronize.py
@@ -21,10 +21,15 @@ def __check_new_videos_sub(subscription: Subscription, yt_api: YoutubeAPI):
results = Video.objects.filter(video_id=video.getVideoId(), subscription=subscription)
if len(results) == 0:
log.info('New video for subscription %s: %s %s"', subscription, video.getVideoId(), video.getTitle())
- create_video(video, subscription)
+ db_video = create_video(video, subscription)
else:
- # TODO... update view count, rating etc
- pass
+ db_video = results.first()
+
+ # Update video stats - rating and view count
+ stats = yt_api.get_single_video_stats(db_video.video_id)
+ db_video.rating = stats.get_like_count() / (stats.get_like_count() + stats.get_dislike_count())
+ db_video.views = stats.get_view_count()
+ db_video.save()
def __detect_deleted(subscription: Subscription):
diff --git a/YtManagerApp/management/videos.py b/YtManagerApp/management/videos.py
index 303c0cf..4853593 100644
--- a/YtManagerApp/management/videos.py
+++ b/YtManagerApp/management/videos.py
@@ -19,6 +19,7 @@ def create_video(yt_video: YoutubePlaylistItem, subscription: Subscription):
video.icon_default = yt_video.getDefaultThumbnailUrl()
video.icon_best = yt_video.getBestThumbnailUrl()
video.save()
+ return video
def get_videos(user: User,
diff --git a/YtManagerApp/static/YtManagerApp/css/style.css b/YtManagerApp/static/YtManagerApp/css/style.css
index c3878fc..ee6b916 100644
--- a/YtManagerApp/static/YtManagerApp/css/style.css
+++ b/YtManagerApp/static/YtManagerApp/css/style.css
@@ -92,6 +92,8 @@
margin-right: -0.25rem; }
.video-gallery .card .card-more:hover {
text-decoration: none; }
+.video-gallery .card .progress {
+ width: 100px; }
.video-gallery .video-icon-yes {
color: #007bff; }
.video-gallery .video-icon-no {
@@ -110,4 +112,8 @@
.modal-field-error ul {
margin: 0; }
+.star-rating {
+ display: inline-block;
+ margin-bottom: 0.5rem; }
+
/*# sourceMappingURL=style.css.map */
diff --git a/YtManagerApp/static/YtManagerApp/css/style.css.map b/YtManagerApp/static/YtManagerApp/css/style.css.map
index 4f3daaf..89c312d 100644
--- a/YtManagerApp/static/YtManagerApp/css/style.css.map
+++ b/YtManagerApp/static/YtManagerApp/css/style.css.map
@@ -1,6 +1,6 @@
{
"version": 3,
-"mappings": "AAEA,OAAQ;EACJ,QAAQ,EAAE,KAAK;EACf,IAAI,EAAE,CAAC;EACP,KAAK,EAAE,CAAC;EACR,MAAM,EAAE,CAAC;EACT,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,SAAS;EAClB,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,MAAM;EACrB,SAAS,EAAE,IAAI;;AAqBnB,uBAAuB;AACvB,kBAAmB;EAlBf,OAAO,EAAE,YAAY;EACrB,KAAK,EAAE,IAAa;EACpB,MAAM,EAAE,IAAa;EAErB,wBAAQ;IACJ,OAAO,EAAE,GAAG;IACZ,OAAO,EAAE,KAAK;IACd,KAAK,EAAE,IAAa;IACpB,MAAM,EAAE,IAA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,KAAK,EAAE,OAAO;;AAItB,WAAY;EACR,SAAS,EAAE,KAAK;EAChB,MAAM,EAAE,MAAM;;AAId,2BAAe;EACX,OAAO,EAAE,IAAI;;AAIrB,kBAAmB;EACf,MAAM,EAAE,QAAQ;EAChB,OAAO,EAAE,QAAQ;EAEjB,qBAAG;IACC,MAAM,EAAE,CAAC;;AAIjB,YAAa;EACT,OAAO,EAAE,YAAY;EACrB,aAAa,EAAE,MAAM",
"sources": ["style.scss"],
"names": [],
"file": "style.css"
diff --git a/YtManagerApp/static/YtManagerApp/css/style.scss b/YtManagerApp/static/YtManagerApp/css/style.scss
index 8d25464..8a40a12 100644
--- a/YtManagerApp/static/YtManagerApp/css/style.scss
+++ b/YtManagerApp/static/YtManagerApp/css/style.scss
@@ -104,8 +104,12 @@ $accent-color: #007bff;
}
.card-img-top {
-
}
+
+ .progress {
+ width: 100px;
+ }
+
}
.video-icon-yes {
@@ -134,5 +138,9 @@ $accent-color: #007bff;
ul {
margin: 0;
}
+}
+.star-rating {
+ display: inline-block;
+ margin-bottom: 0.5rem;
}
\ No newline at end of file
diff --git a/YtManagerApp/templates/YtManagerApp/index_videos.html b/YtManagerApp/templates/YtManagerApp/index_videos.html
index 4ec153f..058be16 100644
--- a/YtManagerApp/templates/YtManagerApp/index_videos.html
+++ b/YtManagerApp/templates/YtManagerApp/index_videos.html
@@ -1,3 +1,6 @@
+{% load humanize %}
+{% load ratings %}
+
{% for video in videos %}
@@ -11,6 +14,11 @@
{% endif %}
{{ video.name }}
+
+ {{ video.views | intcomma }} views
+ •
+ {{ video.publish_date | naturaltime }}
+
{{ video.description | truncatechars:120 }}