subclass VideoFile

This commit is contained in:
Thomas Peetz
2025-01-24 05:02:08 +01:00
parent 0cc73c09aa
commit 88c623edb7
2 changed files with 9 additions and 11 deletions
@@ -2,7 +2,7 @@ from pathlib import Path
from cement import Controller, ex
from kontor_schema import KontorDB
from kontor_video import VideoLink
from kontor_video import VideoLink, MediaVideo
class Media(Controller):
@@ -20,7 +20,7 @@ class Media(Controller):
updates = db.get_update_list()
self.app.log.info(f"found {len(updates)} links for update")
for file_id, url in updates.items():
link = VideoLink(url)
link = MediaVideo(url)
title = link.get_title()
if title is not None:
db.update_entry('media_file', file_id, {'title': title, 'review': 0,})
@@ -77,14 +77,12 @@ class Media(Controller):
}
if self.app.pargs.link is not None:
data['link_url'] = self.app.pargs.link
if self.app.pargs.dry_run:
print(f"add url {data['link_url']} to database")
else:
db = self.app.kontor_db
result = db.add_link(self.app.pargs.link)
self.log.info(result)
self.app.log.info(f"add url {data['link_url']} to database")
db = self.app.kontor_db
result = db.add_link(self.app.pargs.link)
self.app.log.info(result)
else:
print("no url was given.")
self.app.log.info("no url was given.")
@ex(
help='check files if existing',
@@ -285,11 +285,11 @@ class KontorDB:
if type(existing_value) is not type(update_value):
existing_value = str(existing_value)
if existing_value != update_value:
self.log.info("%s has changed: %s != %s", key, existing_value, update_value)
self.log.info(f"{key} has changed: {existing_value} != {update_value}")
setattr(existing_item, key, update_value)
session.commit()
changed = True
self.log.info("update %s with %s", key, update_value)
self.log.info("update {key} with {update_value}", (key, update_value))
return changed
def add_link(self, link: str) -> dict: