diff --git a/src/imdb_datasets_worker.py b/src/imdb_datasets_worker.py index 9352bb8..51e3b99 100644 --- a/src/imdb_datasets_worker.py +++ b/src/imdb_datasets_worker.py @@ -1,5 +1,6 @@ import sqlite3 import gzip +from loguru import logger conn = sqlite3.connect("imdb_titles.sqlite") c = conn.cursor() @@ -31,7 +32,7 @@ def convert_tsv_to_db(title_basics_tsv): else: year = int(year) - if tt_type not in ("movie", "video"): + if tt_type not in ("movie", "tvMovie", "video"): original_name = None year = None @@ -42,9 +43,9 @@ def convert_tsv_to_db(title_basics_tsv): write_dataset = [] counter = 0 progress_counter += chunk - print(f'Обработано: {progress_counter}') - except Exception as E: - print(E) + logger.info(f'Обработано: {progress_counter}') + except: + logger.exception('Err') pass conn.commit() @@ -62,15 +63,15 @@ def extract_ru_locale_from_tsv(title_akas_tsv): tt_id = int(line[0].split("tt")[1]) tt_type = c.execute(f"SELECT type FROM titles WHERE tt_id={tt_id}").fetchone()[0] - if tt_type not in ("movie", "video"): + if tt_type not in ("movie", "tvMovie", "video"): continue ru_name = line[2] ru_name_writer.append((ru_name, tt_id)) counter += 1 - print(f'Обработано ru_name: {counter}') + logger.info(f'Обработано ru_name: {counter}') - except Exception as E: - print(E) + except: + logger.exception('Err') pass c.executemany("UPDATE titles SET ru_name = ? WHERE tt_id = ?", ru_name_writer) diff --git a/src/listener_context.py b/src/listener_context.py index 298ea8b..8dfccaf 100644 --- a/src/listener_context.py +++ b/src/listener_context.py @@ -111,7 +111,7 @@ def scan_context_thread(): if movie[index_type] == "404": message_writer.append("❌ Не найдено.") fail_limit[acct] += 1 - elif movie[index_type] not in ("movie", "video"): + elif movie[index_type] not in ("movie", "tvMovie", "video"): type_of_title = movie[index_type] message_writer.append(f"❌ Не принято:\n- Нам не подходят: сериалы, короткометражные и документальные фильмы") logger.info(f'Предложение {acct} отклонено: не подходящий тип фильма: {type_of_title}')