add elad files

This commit is contained in:
2023-07-15 18:11:30 +03:00
parent 1c1a003647
commit 77c7956e55
9 changed files with 334 additions and 0 deletions

31
utils.py Normal file
View File

@@ -0,0 +1,31 @@
import json
import yaml
import re
from constants import SERIES_NAME_YEAR_PATTERN
def get_credentials():
with open('credentials.yaml') as file:
sdarot_credentials = yaml.full_load(file)
return sdarot_credentials.get('username'), sdarot_credentials.get('password')
def save_cookies(cookies):
with open('cookie.json') as cookie_file:
json.dump(cookies, cookie_file)
def save_series_dictionary(series_json):
with open('series.json', 'w') as file:
json.dump(series_json, file)
def get_matched_series_ids(series_dictionary, series_name):
year = ''
match = re.match(SERIES_NAME_YEAR_PATTERN, series_name)
if match:
series_name = match.group(1)
year = match.group(2)
return list(filter(lambda obj: (series_name in obj['eng'].lower() or series_name in obj['heb']) and year in obj['year'], series_dictionary))