diff --git a/download.py b/download.py index d76ab85..f5e439a 100644 --- a/download.py +++ b/download.py @@ -2,6 +2,7 @@ import aria2p import subprocess import keyboard import os +from scraper import uri aria2 = aria2p.API( aria2p.Client( @@ -35,8 +36,8 @@ def startDownload(_): def terminate(): return -print("Enter Download URL: ") -uri = input() +# print("Enter Download URL: ") +# uri = input() #Magnet Download # downloads_dir = os.path.join(os.path.expanduser("~"), "Downloads") diff --git a/scraper.py b/scraper.py index 4c6ff37..6e2f77c 100644 --- a/scraper.py +++ b/scraper.py @@ -10,19 +10,22 @@ if response.status_code == 200: soup = BeautifulSoup(response.text, "html.parser") links = soup.find_all("a") + + games_dict = {} for link in links: href = link.get("href", "").lower() text = link.text.strip() - if re.search(r"/Discord/", href): + if re.search(r"/discord/", href): continue + + if text: + games_dict[text] = href - games = soup.find_all("li") - game_titles = [game.text.strip() for game in games] + game_titles = list(games_dict.keys()) if game_titles: - print("Games Found:") for title in game_titles: pass else: @@ -39,11 +42,63 @@ search_results = search_games(search_query, game_titles) if search_results: print("Search Results:") - for result in search_results: - print(result) + for idx, result in enumerate(search_results, start=1): + print(f"{idx}. {result}") + + try: + selection = int(input("Select a game by entering the corresponding number: ")) + if 1 <= selection <= len(search_results): + selected_game = search_results[selection - 1] + selected_link = games_dict[selected_game] # Retrieve the link from the dictionary + print(f"You selected: {selected_game}") + print(f"Link: https://steamrip.com{selected_link}") + else: + print("Invalid selection.") + except ValueError: + print("Invalid input. Please enter a number.") else: print("No matching game titles found.") +#scrape download links +game_url = f"https://steamrip.com{selected_link}" + +keywords = ["megadb.com", "buzzheavier.com", "gofile.io"] + +def scrape_buzzheavier(url): + try: + response = requests.get(url) + response.raise_for_status() + soup = BeautifulSoup(response.text, 'html.parser') + links = soup.find_all('a', href=True) + for link in links: + href = link['href'] + full_dl_url = f"https:{href}" if href.startswith("//") else href + if full_dl_url.startswith("https://buzzheavier.com/dl/"): + print(f"Found direct download link: {full_dl_url}") + return + print(f"No direct download link found on {url}") + except requests.RequestException as e: + print(f"Failed to fetch {url}: {e}") + + +def scrape_links(url): + try: + response = requests.get(url) + response.raise_for_status() + soup = BeautifulSoup(response.text, 'html.parser') + links = soup.find_all('a', href=True) + for link in links: + href = link['href'] + full_url = f"https:{href}" if href.startswith("//") else href + if any(keyword in full_url for keyword in keywords): + print(f"Found link: {full_url} on site: {url}") + if "buzzheavier.com" in full_url: + scrape_buzzheavier(full_url) + except requests.RequestException as e: + print(f"Failed to fetch {url}: {e}") + +scrape_links(game_url) + # url = "https://cs.rin.ru/" # url = "https://gamesdrive.net/" # url = "https://gog-games.to/"