Spaces:
Build error
Build error
Commit ·
487a828
1
Parent(s): 86769fb
fix
Browse files2 unmodified lines34567891013 unmodified lines2425262728292 unmodified linesimport urllib.parsefrom hf_scrapper import download_and_cache_file, get_system_proxiesfrom indexer import indexerfrom dotenv import load_dotenvimport jsonload_dotenv()INDEX_FILE = os.getenv("INDEX_FILE")13 unmodified lineswith open(INDEX_FILE, 'r') as f:file_structure = json.load(f)app = Flask(__name__)def get_film_file_path(title):2 unmodified lines34567891011121313 unmodified lines272829303132333435363738394041424344454647484950515253545556575859606162632 unmodified linesimport urllib.parsefrom hf_scrapper import download_and_cache_file, get_system_proxiesfrom indexer import indexerfrom tvdb import fetch_and_cache_jsonfrom dotenv import load_dotenvimport jsonimport refrom threading import Threadload_dotenv()INDEX_FILE = os.getenv("INDEX_FILE")13 unmodified lineswith open(INDEX_FILE, 'r') as f:file_structure = json.load(f)def prefetch_metadata():for item in file_structure:if 'contents' in item:for sub_item in item['contents']:original_title = sub_item['path'].split('/')[-1]media_type = 'series' if item['path'].startswith('tv') else 'movie'title = original_titleyear = Nonematch = re.search(r'\((\d{4})\)', original_title)if match:year_str = match.group(1)if year_str.isdigit() and len(year_str) == 4:title = original_title[:match.start()].strip()year = int(year_str)else:parts = original_title.rsplit(' ', 1)if len(parts) > 1 and parts[-1].isdigit() and len(parts[-1]) == 4:title = parts[0].strip()year = int(parts[-1])fetch_and_cache_json(original_title, title, media_type, year)def start_prefetching():prefetch_metadata()thread = Thread(target=start_prefetching)thread.daemon = Truethread.start()app = Flask(__name__)def get_film_file_path(title):
app.py+34