Fixed synchronize statistics issues. Added current state to readme.

This commit is contained in:
2018-10-29 23:04:10 +02:00
parent c07d1b61f0
commit 97e7e792f8
3 changed files with 74 additions and 56 deletions

View File

@ -31,8 +31,12 @@ def __check_new_videos_sub(subscription: Subscription, yt_api: youtube.YoutubeAP
for yt_video in yt_api.videos(all_vids_ids, part='id,statistics'):
video = all_vids_dict.get(yt_video.id)
if yt_video.like_count is not None and yt_video.dislike_count is not None:
if yt_video.n_likes is not None \
and yt_video.n_dislikes is not None \
and yt_video.n_likes + yt_video.n_dislikes > 0:
video.rating = yt_video.n_likes / (yt_video.n_likes + yt_video.n_dislikes)
video.views = yt_video.n_views
video.save()