mirror of
https://gitea.phreedom.club/localhost_frssoft/FMN_bot.git
synced 2024-11-22 13:01:27 +00:00
Fix movies type
This commit is contained in:
parent
db8a80cfb0
commit
f6b7d41df5
|
@ -1,5 +1,6 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import gzip
|
import gzip
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
conn = sqlite3.connect("imdb_titles.sqlite")
|
conn = sqlite3.connect("imdb_titles.sqlite")
|
||||||
c = conn.cursor()
|
c = conn.cursor()
|
||||||
|
@ -31,7 +32,7 @@ def convert_tsv_to_db(title_basics_tsv):
|
||||||
else:
|
else:
|
||||||
year = int(year)
|
year = int(year)
|
||||||
|
|
||||||
if tt_type not in ("movie", "video"):
|
if tt_type not in ("movie", "tvMovie", "video"):
|
||||||
original_name = None
|
original_name = None
|
||||||
year = None
|
year = None
|
||||||
|
|
||||||
|
@ -42,9 +43,9 @@ def convert_tsv_to_db(title_basics_tsv):
|
||||||
write_dataset = []
|
write_dataset = []
|
||||||
counter = 0
|
counter = 0
|
||||||
progress_counter += chunk
|
progress_counter += chunk
|
||||||
print(f'Обработано: {progress_counter}')
|
logger.info(f'Обработано: {progress_counter}')
|
||||||
except Exception as E:
|
except:
|
||||||
print(E)
|
logger.exception('Err')
|
||||||
pass
|
pass
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
|
@ -62,15 +63,15 @@ def extract_ru_locale_from_tsv(title_akas_tsv):
|
||||||
|
|
||||||
tt_id = int(line[0].split("tt")[1])
|
tt_id = int(line[0].split("tt")[1])
|
||||||
tt_type = c.execute(f"SELECT type FROM titles WHERE tt_id={tt_id}").fetchone()[0]
|
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
|
continue
|
||||||
ru_name = line[2]
|
ru_name = line[2]
|
||||||
ru_name_writer.append((ru_name, tt_id))
|
ru_name_writer.append((ru_name, tt_id))
|
||||||
counter += 1
|
counter += 1
|
||||||
print(f'Обработано ru_name: {counter}')
|
logger.info(f'Обработано ru_name: {counter}')
|
||||||
|
|
||||||
except Exception as E:
|
except:
|
||||||
print(E)
|
logger.exception('Err')
|
||||||
pass
|
pass
|
||||||
|
|
||||||
c.executemany("UPDATE titles SET ru_name = ? WHERE tt_id = ?", ru_name_writer)
|
c.executemany("UPDATE titles SET ru_name = ? WHERE tt_id = ?", ru_name_writer)
|
||||||
|
|
|
@ -111,7 +111,7 @@ def scan_context_thread():
|
||||||
if movie[index_type] == "404":
|
if movie[index_type] == "404":
|
||||||
message_writer.append("❌ Не найдено.")
|
message_writer.append("❌ Не найдено.")
|
||||||
fail_limit[acct] += 1
|
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]
|
type_of_title = movie[index_type]
|
||||||
message_writer.append(f"❌ Не принято:\n- Нам не подходят: сериалы, короткометражные и документальные фильмы")
|
message_writer.append(f"❌ Не принято:\n- Нам не подходят: сериалы, короткометражные и документальные фильмы")
|
||||||
logger.info(f'Предложение {acct} отклонено: не подходящий тип фильма: {type_of_title}')
|
logger.info(f'Предложение {acct} отклонено: не подходящий тип фильма: {type_of_title}')
|
||||||
|
|
Loading…
Reference in a new issue