Fix movies type

This commit is contained in:
localhost_frssoft 2022-09-19 14:56:42 +03:00
parent db8a80cfb0
commit f6b7d41df5
2 changed files with 10 additions and 9 deletions

View file

@ -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)

View file

@ -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}')