Vorbereitung Release 0.2.0 #83

Merged
tpeetz merged 178 commits from develop/0.2.0 into main 2026-01-29 22:50:42 +00:00
Showing only changes of commit 2fa77d3af6 - Show all commits
+20 -17
View File
@@ -46,8 +46,10 @@ def get_logger(level: int) -> logging.Logger:
if level is not None:
match level:
case 0:
logger.setLevel(logging.INFO)
logger.setLevel(logging.WARNING)
case 1:
logger.setLevel(logging.INFO)
case 2:
logger.setLevel(logging.DEBUG)
case _:
logger.setLevel(logging.CRITICAL)
@@ -55,8 +57,8 @@ def get_logger(level: int) -> logging.Logger:
def update_file(log: logging.Logger, media_file):
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{media_file['id']}", json=media_file)
log.info(f"update status: {update.status_code}")
log.info(f"update result: {update.json()}")
log.debug(f"update status: {update.status_code}")
log.debug(f"update result: {update.json()}")
def get_actor_links(log: logging.Logger, media_file_url: str) -> list:
try:
@@ -64,7 +66,7 @@ def get_actor_links(log: logging.Logger, media_file_url: str) -> list:
soup = BeautifulSoup(r.content, "html.parser")
error404 = soup.css.select_one('.error404-title')
if error404 and error404.get_text() == "Video nicht gefunden":
log.info(f"{error404.get_text()}")
log.warning(f"{error404.get_text()}")
item['url'] = None
item['review'] = False
update_file(log, item)
@@ -76,17 +78,17 @@ def get_actor_links(log: logging.Logger, media_file_url: str) -> list:
if link_url.endswith('all/countries'):
continue
actor_links.append(link_url)
log.info(f"links({len(actor_links)}): {actor_links}")
log.debug(f"links({len(actor_links)}): {actor_links}")
return actor_links
except Exception as error:
log.info(f"something went wrong: {error}")
log.warning(f"something went wrong: {error}")
return []
if __name__ == '__main__':
log = get_logger(args.verbose)
log.info('kontor.find_links started')
log.info('get all actors')
log.warning('kontor.find_links started')
log.debug('get all actors')
response = requests.get("http://127.0.0.1:8800/api/media/actors")
data = response.json()
actors = {}
@@ -103,28 +105,29 @@ if __name__ == '__main__':
else:
files_url = "http://127.0.0.1:8800/api/media/files?review=true"
response = requests.get(files_url)
log.info(f"Status: {response.status_code}")
log.debug(f"Status: {response.status_code}")
data = response.json()
log.info(f"data: {len(data)}")
log.debug(f"data: {len(data)}")
for item in data:
link = item['url']
if not link:
continue
if str(link) == "None":
continue
log.info(f"{item['id']} - {str(link)}")
log.warning(f"{item['id']} - {str(link)}")
actor_links = get_actor_links(log, link)
actor_list = []
for actor_link in actor_links:
if actor_link in actors:
log.info(f"found actor with id: {actors[actor_link]['id']}")
log.debug(f"found actor with id: {actors[actor_link]['id']}")
actor_list.append(actors[actor_link])
actor_response = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}/actors", json=actor_list)
actor_data = actor_response.json()
log.info(f"found {len(actor_data)} actors")
log.info(f"found actors: {actor_data}")
log.warning(f"{len(actor_data)} links persisted, but {len(actor_list)} links are available")
log.debug(f"found {len(actor_data)} actors")
log.debug(f"found actors: {actor_data}")
item['review'] = False
update = requests.put(f"http://127.0.0.1:8800/api/media/files/{item['id']}", json=item)
log.info(f"update status: {update.status_code}")
log.info(f"update result: {update.json()}")
log.info('kontor.find_links finished')
log.debug(f"update status: {update.status_code}")
log.debug(f"update result: {update.json()}")
log.warning('kontor.find_links finished')