Fix subscriptions new video count when there are deleted videos
It would be 30 since the old method looked to see where the latest video in the database is in the new batch of videos. New method finds the first video in the new batch which is in the database.
This commit is contained in:
parent
c6fe9b8fc7
commit
af334a8ac7
@ -531,22 +531,19 @@ def _get_upstream_videos(channel_id):
|
|||||||
with connection as cursor:
|
with connection as cursor:
|
||||||
|
|
||||||
# calculate how many new videos there are
|
# calculate how many new videos there are
|
||||||
row = cursor.execute('''SELECT video_id
|
existing_vids = set(row[0] for row in cursor.execute(
|
||||||
FROM videos
|
'''SELECT video_id
|
||||||
INNER JOIN subscribed_channels ON videos.sql_channel_id = subscribed_channels.id
|
FROM videos
|
||||||
WHERE yt_channel_id=?
|
INNER JOIN subscribed_channels
|
||||||
ORDER BY time_published DESC
|
ON videos.sql_channel_id = subscribed_channels.id
|
||||||
LIMIT 1''', [channel_id]).fetchone()
|
WHERE yt_channel_id=?
|
||||||
if row is None:
|
ORDER BY time_published DESC
|
||||||
number_of_new_videos = len(videos)
|
LIMIT 30''', [channel_id]).fetchall())
|
||||||
else:
|
number_of_new_videos = 0
|
||||||
latest_video_id = row[0]
|
for video in videos:
|
||||||
index = 0
|
if video['id'] in existing_vids:
|
||||||
for video in videos:
|
break
|
||||||
if video['id'] == latest_video_id:
|
number_of_new_videos += 1
|
||||||
break
|
|
||||||
index += 1
|
|
||||||
number_of_new_videos = index
|
|
||||||
|
|
||||||
is_first_check = cursor.execute('''SELECT time_last_checked FROM subscribed_channels WHERE yt_channel_id=?''', [channel_id]).fetchone()[0] in (None, 0)
|
is_first_check = cursor.execute('''SELECT time_last_checked FROM subscribed_channels WHERE yt_channel_id=?''', [channel_id]).fetchone()[0] in (None, 0)
|
||||||
time_videos_retrieved = int(time.time())
|
time_videos_retrieved = int(time.time())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user