subclass VideoFile
This commit is contained in:
@@ -2,7 +2,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from cement import Controller, ex
|
from cement import Controller, ex
|
||||||
from kontor_schema import KontorDB
|
from kontor_schema import KontorDB
|
||||||
from kontor_video import VideoLink
|
from kontor_video import VideoLink, MediaVideo
|
||||||
|
|
||||||
|
|
||||||
class Media(Controller):
|
class Media(Controller):
|
||||||
@@ -20,7 +20,7 @@ class Media(Controller):
|
|||||||
updates = db.get_update_list()
|
updates = db.get_update_list()
|
||||||
self.app.log.info(f"found {len(updates)} links for update")
|
self.app.log.info(f"found {len(updates)} links for update")
|
||||||
for file_id, url in updates.items():
|
for file_id, url in updates.items():
|
||||||
link = VideoLink(url)
|
link = MediaVideo(url)
|
||||||
title = link.get_title()
|
title = link.get_title()
|
||||||
if title is not None:
|
if title is not None:
|
||||||
db.update_entry('media_file', file_id, {'title': title, 'review': 0,})
|
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:
|
if self.app.pargs.link is not None:
|
||||||
data['link_url'] = self.app.pargs.link
|
data['link_url'] = self.app.pargs.link
|
||||||
if self.app.pargs.dry_run:
|
self.app.log.info(f"add url {data['link_url']} to database")
|
||||||
print(f"add url {data['link_url']} to database")
|
|
||||||
else:
|
|
||||||
db = self.app.kontor_db
|
db = self.app.kontor_db
|
||||||
result = db.add_link(self.app.pargs.link)
|
result = db.add_link(self.app.pargs.link)
|
||||||
self.log.info(result)
|
self.app.log.info(result)
|
||||||
else:
|
else:
|
||||||
print("no url was given.")
|
self.app.log.info("no url was given.")
|
||||||
|
|
||||||
@ex(
|
@ex(
|
||||||
help='check files if existing',
|
help='check files if existing',
|
||||||
|
|||||||
@@ -285,11 +285,11 @@ class KontorDB:
|
|||||||
if type(existing_value) is not type(update_value):
|
if type(existing_value) is not type(update_value):
|
||||||
existing_value = str(existing_value)
|
existing_value = str(existing_value)
|
||||||
if existing_value != update_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)
|
setattr(existing_item, key, update_value)
|
||||||
session.commit()
|
session.commit()
|
||||||
changed = True
|
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
|
return changed
|
||||||
|
|
||||||
def add_link(self, link: str) -> dict:
|
def add_link(self, link: str) -> dict:
|
||||||
|
|||||||
Reference in New Issue
Block a user