Add column last_refresh to channels.
This commit is contained in:
parent
cc7c88abc9
commit
4d7b396e0c
4 changed files with 49 additions and 2 deletions
|
@ -314,6 +314,39 @@ def upgrade_9_to_10(ycdldb):
|
||||||
|
|
||||||
m.go()
|
m.go()
|
||||||
|
|
||||||
|
def upgrade_10_to_11(ycdldb):
|
||||||
|
'''
|
||||||
|
In this version, the `last_refresh` column was added to the channels table.
|
||||||
|
'''
|
||||||
|
m = Migrator(ycdldb)
|
||||||
|
|
||||||
|
m.tables['channels']['create'] = '''
|
||||||
|
CREATE TABLE IF NOT EXISTS channels(
|
||||||
|
id TEXT,
|
||||||
|
name TEXT,
|
||||||
|
uploads_playlist TEXT,
|
||||||
|
download_directory TEXT COLLATE NOCASE,
|
||||||
|
queuefile_extension TEXT COLLATE NOCASE,
|
||||||
|
automark TEXT,
|
||||||
|
autorefresh INT,
|
||||||
|
last_refresh INT
|
||||||
|
);
|
||||||
|
'''
|
||||||
|
m.tables['channels']['transfer'] = '''
|
||||||
|
INSERT INTO channels SELECT
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
uploads_playlist,
|
||||||
|
download_directory,
|
||||||
|
queuefile_extension,
|
||||||
|
automark,
|
||||||
|
autorefresh,
|
||||||
|
NULL
|
||||||
|
FROM channels_old;
|
||||||
|
'''
|
||||||
|
|
||||||
|
m.go()
|
||||||
|
|
||||||
def upgrade_all(data_directory):
|
def upgrade_all(data_directory):
|
||||||
'''
|
'''
|
||||||
Given the directory containing a ycdl database, apply all of the
|
Given the directory containing a ycdl database, apply all of the
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from voussoirkit import sqlhelpers
|
from voussoirkit import sqlhelpers
|
||||||
|
|
||||||
DATABASE_VERSION = 10
|
DATABASE_VERSION = 11
|
||||||
|
|
||||||
DB_INIT = f'''
|
DB_INIT = f'''
|
||||||
CREATE TABLE IF NOT EXISTS channels(
|
CREATE TABLE IF NOT EXISTS channels(
|
||||||
|
@ -10,7 +10,8 @@ CREATE TABLE IF NOT EXISTS channels(
|
||||||
download_directory TEXT COLLATE NOCASE,
|
download_directory TEXT COLLATE NOCASE,
|
||||||
queuefile_extension TEXT COLLATE NOCASE,
|
queuefile_extension TEXT COLLATE NOCASE,
|
||||||
automark TEXT,
|
automark TEXT,
|
||||||
autorefresh INT
|
autorefresh INT,
|
||||||
|
last_refresh INT
|
||||||
);
|
);
|
||||||
CREATE INDEX IF NOT EXISTS index_channel_id on channels(id);
|
CREATE INDEX IF NOT EXISTS index_channel_id on channels(id);
|
||||||
----------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------
|
||||||
|
|
|
@ -4,6 +4,7 @@ import typing
|
||||||
|
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
from voussoirkit import stringtools
|
from voussoirkit import stringtools
|
||||||
|
from voussoirkit import timetools
|
||||||
from voussoirkit import vlogging
|
from voussoirkit import vlogging
|
||||||
from voussoirkit import worms
|
from voussoirkit import worms
|
||||||
|
|
||||||
|
@ -244,6 +245,12 @@ class Channel(ObjectBase):
|
||||||
for video in self.ycdldb.youtube.get_videos(refresh_ids):
|
for video in self.ycdldb.youtube.get_videos(refresh_ids):
|
||||||
self.ycdldb.ingest_video(video)
|
self.ycdldb.ingest_video(video)
|
||||||
|
|
||||||
|
pairs = {
|
||||||
|
'id': self.id,
|
||||||
|
'last_refresh': timetools.now().timestamp(),
|
||||||
|
}
|
||||||
|
self.ycdldb.update(table='channels', pairs=pairs, where_key='id')
|
||||||
|
|
||||||
def reset_uploads_playlist_id(self):
|
def reset_uploads_playlist_id(self):
|
||||||
'''
|
'''
|
||||||
Reset the stored uploads_playlist id with current data from the API.
|
Reset the stored uploads_playlist id with current data from the API.
|
||||||
|
|
|
@ -5,6 +5,7 @@ from voussoirkit import cacheclass
|
||||||
from voussoirkit import configlayers
|
from voussoirkit import configlayers
|
||||||
from voussoirkit import lazychain
|
from voussoirkit import lazychain
|
||||||
from voussoirkit import pathclass
|
from voussoirkit import pathclass
|
||||||
|
from voussoirkit import timetools
|
||||||
from voussoirkit import vlogging
|
from voussoirkit import vlogging
|
||||||
from voussoirkit import worms
|
from voussoirkit import worms
|
||||||
|
|
||||||
|
@ -130,6 +131,11 @@ class YCDLDBChannelMixin:
|
||||||
try:
|
try:
|
||||||
most_recent_video = channel.get_most_recent_video_id()
|
most_recent_video = channel.get_most_recent_video_id()
|
||||||
new_ids = ytrss.get_user_videos_since(channel.id, most_recent_video)
|
new_ids = ytrss.get_user_videos_since(channel.id, most_recent_video)
|
||||||
|
pairs = {
|
||||||
|
'id': channel.id,
|
||||||
|
'last_refresh': timetools.now().timestamp(),
|
||||||
|
}
|
||||||
|
self.update(table='channels', pairs=pairs, where_key='id')
|
||||||
yield from new_ids
|
yield from new_ids
|
||||||
except (exceptions.NoVideos, exceptions.RSSAssistFailed) as exc:
|
except (exceptions.NoVideos, exceptions.RSSAssistFailed) as exc:
|
||||||
log.debug(
|
log.debug(
|
||||||
|
|
Loading…
Reference in a new issue