Add episode art URL and chapters to database.

Co-authored-by: Eric Le Lay <elelay@macports.org>
This commit is contained in:
auouymous 2022-03-20 19:03:46 -06:00
parent 4d4ad7f7cb
commit 97d9459b90
2 changed files with 19 additions and 3 deletions

View File

@ -368,8 +368,10 @@ class PodcastEpisode(PodcastModelObject):
self.file_size = 0
self.mime_type = 'application/octet-stream'
self.guid = ''
self.episode_art_url = None
self.description = ''
self.description_html = ''
self.chapters = None
self.link = ''
self.published = 0
self.download_filename = None
@ -864,7 +866,8 @@ class PodcastEpisode(PodcastModelObject):
return '-'
def update_from(self, episode):
for k in ('title', 'url', 'description', 'description_html', 'link', 'published', 'guid', 'payment_url'):
for k in ('title', 'url', 'episode_art_url', 'description', 'description_html', 'chapters', 'link',
'published', 'guid', 'payment_url'):
setattr(self, k, getattr(episode, k))
# Don't overwrite file size on downloaded episodes
# See #648 refreshing a youtube podcast clears downloaded file size

View File

@ -50,6 +50,8 @@ EpisodeColumns = (
'last_playback',
'payment_url',
'description_html',
'episode_art_url',
'chapters',
)
PodcastColumns = (
@ -72,7 +74,7 @@ PodcastColumns = (
'cover_thumb',
)
CURRENT_VERSION = 7
CURRENT_VERSION = 8
# SQL commands to upgrade old database versions to new ones
@ -114,6 +116,13 @@ UPGRADE_SQL = [
UPDATE episode SET description=remove_html_tags(description_html) WHERE is_html(description)
UPDATE podcast SET http_last_modified=NULL, http_etag=NULL
"""),
# Version 8: Add episode thumbnail URL and chapters
(7, 8, """
ALTER TABLE episode ADD COLUMN episode_art_url TEXT NULL DEFAULT NULL
ALTER TABLE episode ADD COLUMN chapters TEXT NULL DEFAULT NULL
UPDATE podcast SET http_last_modified=NULL, http_etag=NULL
"""),
]
@ -172,7 +181,9 @@ def initialize_database(db):
current_position_updated INTEGER NOT NULL DEFAULT 0,
last_playback INTEGER NOT NULL DEFAULT 0,
payment_url TEXT NULL DEFAULT NULL,
description_html TEXT NOT NULL DEFAULT ''
description_html TEXT NOT NULL DEFAULT '',
episode_art_url TEXT NULL DEFAULT NULL,
chapters TEXT NULL DEFAULT NULL
)
""")
@ -299,6 +310,8 @@ def convert_gpodder2_db(old_db, new_db):
0,
None,
'',
None,
None,
)
new_db.execute("""
INSERT INTO episode VALUES (%s)