From fa6f7fb436e4b1cba41b4cc7d6b8452f4917569e Mon Sep 17 00:00:00 2001 From: TylerCG <117808427+TylerCG@users.noreply.github.com> Date: Sun, 20 Apr 2025 11:19:11 -0400 Subject: [PATCH] commit --- app/download.py | 40 ++++++++++++++++++---------------------- app/main.py | 6 +++++- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/app/download.py b/app/download.py index fd08499..2688b31 100644 --- a/app/download.py +++ b/app/download.py @@ -78,30 +78,26 @@ class dropout(): def series(): json_data=[] - try: - page_html=requests.get('https://www.dropout.tv/series') - # If you want to parse the HTML - soup = BeautifulSoup(page_html.text, 'html.parser') - # Example: Find all elements with a specific class - elements = soup.find_all(class_='browse-item-link') - # Extract URLs from href attributes - urls = [element['href'] for element in elements if 'href' in element.attrs] + page_html=requests.get('https://www.dropout.tv/series') + # If you want to parse the HTML + soup = BeautifulSoup(page_html.text, 'html.parser') + # Example: Find all elements with a specific class + elements = soup.find_all(class_='browse-item-link') + # Extract URLs from href attributes + urls = [element['href'] for element in elements if 'href' in element.attrs] - for url in urls: - info_data={} - name=url.replace('https://www.dropout.tv/','').replace('-s-',"'s-").replace('-',' ').title().replace('Of','of').replace("'S","'s") - info_data['SHOW'] = name - info_data['URL'] = url - info_data['SEASONS'] = grab.season(url) - json_data.append(info_data) + for url in urls: + info_data={} + name=url.replace('https://www.dropout.tv/','').replace('-s-',"'s-").replace('-',' ').title().replace('Of','of').replace("'S","'s") + info_data['SHOW'] = name + info_data['URL'] = url + info_data['SEASONS'] = grab.season(url) + json_data.append(info_data) - # Sort the json_data by the 'SHOW' key - sorted_json_data = sorted(json_data, key=lambda x: x['SHOW']) - with open('/data/dropout.json', 'w') as json_file: - json.dump(sorted_json_data, json_file, indent=4) - return JSONResponse(status_code=200, content={"status": "success", "message": "Series information gather successfully."}) - except Exception as e: - return JSONResponse(status_code=500, content={"status": "error", "message": str(e)}) + # Sort the json_data by the 'SHOW' key + sorted_json_data = sorted(json_data, key=lambda x: x['SHOW']) + with open('/data/dropout.json', 'w') as json_file: + json.dump(sorted_json_data, json_file, indent=4) class youtube(): def ydl(url, location): diff --git a/app/main.py b/app/main.py index 3eff665..1ff6156 100644 --- a/app/main.py +++ b/app/main.py @@ -19,7 +19,11 @@ templates = Jinja2Templates(directory="/app/templates") # api @app.get("/dropoutUpdate") async def dropoutUpdate(): - return await run_in_threadpool(download.dropout.series()) + try: + download.dropout.series() + return JSONResponse(status_code=200, content={"status": "success", "message": "Series information gather successfully."}) + except Exception as e: + return JSONResponse(status_code=500, content={"status": "error", "message": str(e)}) @app.get("/dropoutSeries", response_class=JSONResponse) async def dropoutSeries():