BinaryONe commited on
Commit ·
87159d4
1
Parent(s): 72617d0
APP-API-Endpoints Modifications -sparkdrive
Browse filesFiles changed (3)
4 unmodified lines5678910111213141515 unmodified lines313233343536374 unmodified linesdef get_tvshows(tv_show_id):return tv.details(tv_show_id).__dict__def search_tmdb(name):# Search for the title in TMDbtitle, year = Get_Title_Year(name)print("*", title, year,"\n Name :", name)if title is None :return Nonesearch_results = search.multi(title)15 unmodified linesreturn resultexcept Exception as e :#print("* Error at Endpoint", e, result)return Nonereturn None4 unmodified lines567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545515 unmodified lines717273747576774 unmodified linesdef get_tvshows(tv_show_id):return tv.details(tv_show_id).__dict__def search_tmdb_movies(name):# Search for the title in TMDbtitle, year = Get_Title_Year(name)#print("*", title, year,"\n Name :", name)if title is None :return Nonesearch_results = search.multi(title)# Filter results by yeartry:for result in search_results:if result.media_type == "movie":release_date=result.release_date or result.get("release_date") or result.get("first_air_date")if release_date and int(release_date.split('-')[0]) == year:return resultexcept Exception as e :print("* Error at Endpoint", e, result)return Nonereturn Nonedef search_tmdb_tv(name):# Search for the title in TMDbtitle, year = Get_Title_Year(name)#print("*", title, year,"\n Name :", name)if title is None :return Nonesearch_results = search.multi(title)# Filter results by yeartry:for result in search_results:if result.media_type == "tv":release_date=result.release_date or result.first_air_date or result.get("release_date") or result.get("first_air_date")if release_date and int(release_date.split('-')[0]) == year:return get_tvshows( result.id or result.get("id") )except Exception as e :print("* Error at Endpoint", e, result)return Nonereturn Nonedef search_tmdb_any(name):# Search for the title in TMDbtitle, year = Get_Title_Year(name)#print("*", title, year,"\n Name :", name)if title is None :return Nonesearch_results = search.multi(title)15 unmodified linesreturn resultexcept Exception as e :print("* Error at Endpoint", e, result)return Nonereturn None
19 unmodified lines20212223242517 unmodified lines43444546474849505119 unmodified linestext = re.sub(r'[^A-Za-z0-9 ]+', '', text)return textdef clean_text(input_text):# Remove new line characterstext = input_text.replace('\n', '').replace('@', '')17 unmodified linesdef Get_Title_Year(name):# Regex to match title and yearwords_to_remove = ["FC", "HEVC","ɴᴀᴍᴇ:","-","BuLMoviee" ,"𝗝𝗼𝗶𝗻 𝗨𝘀 𝗢𝗻 𝗧𝗲𝗹𝗲𝗴𝗿𝗮�","𝗝𝗼𝗶𝗻 𝗨𝘀 𝗢𝗻 𝗧𝗲𝗹𝗲𝗴𝗿𝗮𝗺","SIDHUU 591","𝑱𝒐𝒊𝒏 𝑼𝒔 𝑶ɴ 𝑻ᴇʟᴇɢʀᴀᴍ","Tɪᴛʟᴇ :"]name=remove_words(name, words_to_remove)match = re.search(r'(?P<title>.+?)[\s\.\(\)]*(?P<year>\d{4})',name )if match:return match.group('title').strip(), int(match.group('year'))return None, None19 unmodified lines202122232425262728293031323317 unmodified lines5152535455565758596019 unmodified linestext = re.sub(r'[^A-Za-z0-9 ]+', '', text)return textdef clean_string_special(input_string):# Define a regular expression pattern to remove special characters, including •, ▫️, etc.# This pattern keeps only alphanumeric characters (A-Z, a-z, 0-9) and spaces.cleaned_string = re.sub(r'[^\w\s]+', '', input_string)return cleaned_stringdef clean_text(input_text):# Remove new line characterstext = input_text.replace('\n', '').replace('@', '')17 unmodified linesdef Get_Title_Year(name):# Regex to match title and yearwords_to_remove = ["Fɪʟᴇ ɴᴀᴍᴇ :","FC", "HEVC","ɴᴀᴍᴇ:","-","BuLMoviee" ,"𝗝𝗼𝗶𝗻 𝗨𝘀 𝗢𝗻 𝗧𝗲𝗹𝗲𝗴𝗿𝗮�","𝗝𝗼𝗶𝗻 𝗨𝘀 𝗢𝗻 𝗧𝗲𝗹𝗲𝗴𝗿𝗮𝗺","SIDHUU 591","𝑱𝒐𝒊𝒏 𝑼𝒔 𝑶ɴ 𝑻ᴇʟᴇɢʀᴀᴍ","Tɪᴛʟᴇ :","Bollywood","mkv","Mᴏᴠɪᴇ", "ɢʀᴏᴜᴘ" , "TGxMALLU_MOVIE"]name=remove_words(name, words_to_remove)match = re.search(r'(?P<title>.+?)[\s\.\(\)]*(?P<year>\d{4})',name )if match:return clean_string_special(match.group('title').strip()), int(match.group('year'))return None, None
14 unmodified lines151617181920217 unmodified lines2930313233345 unmodified lines40414243444546474849124 unmodified lines17417517617717817918014 unmodified linesfrom FileStream.bot import req_clientfrom FileStream.config import Telegram,Serverfrom FileStream.Database import Databasefrom FileStream.TMDB.Endpoint import search_tmdbfrom FileStream.server.exceptions import FIleNotFound, InvalidHashfrom .Functions.downloader import media_streamer7 unmodified lines#print(files, type(files))return web.json_response(json.loads(dumps(files)))#api.router.add_get('/tmdb/list', list_all_files_tmdb)async def list_all_files_tmdb(request):5 unmodified lines#print(row['file']['caption'])try :#print("* Response",search_tmdb(row['file']['caption'] if row['file']['caption'] else row['file']['file_name']))resp = search_tmdb( str(row['file']['caption']) if str(row['file']['caption']) else str(row['file']['file_name']))if resp != None :#resp= dict(resp)print("TMDB Response :",resp)response.append(resp)else:print("\n * Skipped:",row['file']['caption'],str(row['file']['file_name']))124 unmodified linesapi = web.Application()api.router.add_get('/', handle_v2)api.router.add_get('/files', list_all_files_db)api.router.add_get('/tmdb/files', list_all_files)api.router.add_get('/tmdb/list', list_all_files_tmdb)api.router.add_get('/upload', upload_file)api.router.add_get('/dl/{path}', stream_handler)14 unmodified lines151617181920217 unmodified lines293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788895 unmodified lines9596979899100101102103104124 unmodified lines22923023123223323423523623723823914 unmodified linesfrom FileStream.bot import req_clientfrom FileStream.config import Telegram,Serverfrom FileStream.Database import Databasefrom FileStream.TMDB.Endpoint import search_tmdb_any,search_tmdb_tv,search_tmdb_moviesfrom FileStream.server.exceptions import FIleNotFound, InvalidHashfrom .Functions.downloader import media_streamer7 unmodified lines#print(files, type(files))return web.json_response(json.loads(dumps(files)))async def list_all_tmdb_movies_from_db(request):db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)files= await db.get_all_files()#print(files)response=[]async for row in files:#print(row['file']['caption'])try :#print("* Response",search_tmdb(row['file']['caption'] if row['file']['caption'] else row['file']['file_name']))resp = search_tmdb_movies( str(row['file']['caption']) if str(row['file']['caption']) else str(row['file']['file_name']))if resp != None :#resp= dict(resp)#print("TMDB Response :",resp)response.append(resp)else:print("\n * Skipped:",row['file']['caption'],str(row['file']['file_name']))continueexcept Exception as e:print("Error ",e)break#print(response)# Convert Python data to JSON#json_response = json.dumps(response).encode('utf-8')# Return as aiohttp response using web.json_response#return web.json_response(response)return web.json_response(json.loads(dumps(response)))async def list_all_tmdb_tv_from_db(request):db = Database(Telegram.DATABASE_URL, Telegram.SESSION_NAME)files= await db.get_all_files()#print(files)response=[]async for row in files:#print(row['file']['caption'])try :#print("* Response",search_tmdb(row['file']['caption'] if row['file']['caption'] else row['file']['file_name']))resp = search_tmdb_tv( str(row['file']['caption']) if str(row['file']['caption']) else str(row['file']['file_name']))if resp != None :#resp= dict(resp)#print("TMDB Response :",resp)response.append(resp)else:print("\n * Skipped:",row['file']['caption'],str(row['file']['file_name']))continueexcept Exception as e:print("Error ",e)break#print(response)# Convert Python data to JSON#json_response = json.dumps(response).encode('utf-8')# Return as aiohttp response using web.json_response#return web.json_response(response)return web.json_response(json.loads(dumps(response)))#api.router.add_get('/tmdb/list', list_all_files_tmdb)async def list_all_files_tmdb(request):5 unmodified lines#print(row['file']['caption'])try :#print("* Response",search_tmdb(row['file']['caption'] if row['file']['caption'] else row['file']['file_name']))resp = search_tmdb_any( str(row['file']['caption']) if str(row['file']['caption']) else str(row['file']['file_name']))if resp != None :#resp= dict(resp)#print("TMDB Response :",resp)response.append(resp)else:print("\n * Skipped:",row['file']['caption'],str(row['file']['file_name']))124 unmodified linesapi = web.Application()api.router.add_get('/', handle_v2)api.router.add_get('/files', list_all_files_db)api.router.add_get('/files/mix', list_all_files)api.router.add_get('/tmdb/mix', list_all_files_tmdb)api.router.add_get('/tmdb/tv', list_all_tmdb_tv_from_db)api.router.add_get('/tmdb/movies', list_all_tmdb_movies_from_db)api.router.add_get('/upload', upload_file)api.router.add_get('/dl/{path}', stream_handler)
FileStream/TMDB/Endpoint.py+43-3
FileStream/Tools/cleanup.py+11-2
FileStream/server/routes_api.py+64-5