mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
feat: add vikingfile and megadb scraping functionality to SteamripScraper
This commit is contained in:
@@ -0,0 +1,14 @@
|
|||||||
|
from utils.logging.logs import consoleLog
|
||||||
|
import webbrowser
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def scrape_megadb(url):
|
||||||
|
match = re.search(r"megadb\.net/([a-zA-Z0-9]+)", url)
|
||||||
|
if not match:
|
||||||
|
consoleLog("MegaDB: Invalid URL")
|
||||||
|
return None
|
||||||
|
|
||||||
|
consoleLog("MegaDB: Captcha required, launching browser...")
|
||||||
|
webbrowser.open(url)
|
||||||
|
return None
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
from utils.logging.logs import consoleLog
|
||||||
|
import webbrowser
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def scrape_vikingfile(url):
|
||||||
|
match = re.search(r"vikingfile\.com/f/([a-zA-Z0-9]+)", url)
|
||||||
|
if not match:
|
||||||
|
consoleLog("VikingFile: Invalid URL")
|
||||||
|
return None
|
||||||
|
|
||||||
|
consoleLog("VikingFile: Captcha required, launching browser...")
|
||||||
|
webbrowser.open(url)
|
||||||
|
return None
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
from data.hosts.buzzheavier import scrape_buzzheavier
|
from data.hosts.buzzheavier import scrape_buzzheavier
|
||||||
from data.hosts.gofile import scrape_gofile
|
from data.hosts.gofile import scrape_gofile
|
||||||
|
from data.hosts.vikingfile import scrape_vikingfile
|
||||||
|
from data.hosts.megadb import scrape_megadb
|
||||||
from utils.logging.logs import consoleLog
|
from utils.logging.logs import consoleLog
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
@@ -25,9 +27,14 @@ class SteamripScraper:
|
|||||||
if self.cache["data"] != [] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
if self.cache["data"] != [] and (current_time - self.cache["last_fetched"] < self.cache_expiry):
|
||||||
return self.cache["data"]
|
return self.cache["data"]
|
||||||
|
|
||||||
url = f"https://steamrip.com/games-list-page/"
|
try:
|
||||||
response = requests.get(url)
|
url = f"https://steamrip.com/games-list-page/"
|
||||||
text = response.text
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
text = response.text
|
||||||
|
except requests.RequestException as e:
|
||||||
|
consoleLog(f"SteamRip: Failed to fetch games list - {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
soup = BeautifulSoup(text, "html.parser")
|
soup = BeautifulSoup(text, "html.parser")
|
||||||
games = soup.find_all("li", class_="az-list-item")
|
games = soup.find_all("li", class_="az-list-item")
|
||||||
@@ -55,17 +62,29 @@ class SteamripScraper:
|
|||||||
return ret
|
return ret
|
||||||
|
|
||||||
def scrape_steamrip_game_downloads(self, url):
|
def scrape_steamrip_game_downloads(self, url):
|
||||||
response = requests.get(url)
|
try:
|
||||||
|
response = requests.get(url)
|
||||||
|
response.raise_for_status()
|
||||||
|
except requests.RequestException as e:
|
||||||
|
consoleLog(f"SteamRip: Failed to fetch game page - {e}")
|
||||||
|
return []
|
||||||
|
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
download_link_elements = soup.find_all("a",class_="shortc-button")
|
download_link_elements = soup.find_all("a",class_="shortc-button")
|
||||||
download_links = ["buzzheavier", "gofile"]
|
download_links = ["buzzheavier", "gofile", "vikingfile", "megadb"]
|
||||||
|
|
||||||
for download_link in download_link_elements:
|
for download_link in download_link_elements:
|
||||||
pure = download_link.attrs.get("href")
|
pure = download_link.attrs.get("href")
|
||||||
|
if not pure or len(pure) < 3:
|
||||||
|
continue
|
||||||
if pure[2] == "b":
|
if pure[2] == "b":
|
||||||
download_links[0] = "https:" + pure
|
download_links[0] = "https:" + pure
|
||||||
if pure[2] == "g":
|
if pure[2] == "g":
|
||||||
download_links[1] = "https:" + pure
|
download_links[1] = "https:" + pure
|
||||||
|
if pure[2] == "v":
|
||||||
|
download_links[2] = "https:" + pure
|
||||||
|
if pure[2] == "m":
|
||||||
|
download_links[3] = "https:" + pure
|
||||||
|
|
||||||
ret = []
|
ret = []
|
||||||
|
|
||||||
@@ -78,21 +97,46 @@ class SteamripScraper:
|
|||||||
def get_download_link(self, post: Dict):
|
def get_download_link(self, post: Dict):
|
||||||
url = post["url"]
|
url = post["url"]
|
||||||
links = self.scrape_steamrip_game_downloads(url)
|
links = self.scrape_steamrip_game_downloads(url)
|
||||||
|
|
||||||
|
if not links:
|
||||||
|
consoleLog("SteamRip: No download links found")
|
||||||
|
return None, None
|
||||||
|
|
||||||
best = ""
|
best = ""
|
||||||
for link in links:
|
for link in links:
|
||||||
if link[0] == "h":
|
if link[0] == "h":
|
||||||
best = link
|
best = link
|
||||||
break
|
break
|
||||||
|
|
||||||
if links.index(best) == 0:
|
if not best:
|
||||||
link = scrape_buzzheavier(best)
|
consoleLog("SteamRip: No valid download links found")
|
||||||
return link
|
return None, None
|
||||||
elif links.index(best) == 1:
|
|
||||||
link, headers = scrape_gofile(best)
|
try:
|
||||||
return link, headers
|
idx = links.index(best)
|
||||||
else:
|
except ValueError:
|
||||||
consoleLog("Unable to retrieve download link due to captcha, launching browser...")
|
consoleLog("SteamRip: Failed to resolve download host")
|
||||||
webbrowser.open(best)
|
return None, None
|
||||||
|
|
||||||
|
try:
|
||||||
|
if idx == 0:
|
||||||
|
link = scrape_buzzheavier(best)
|
||||||
|
return link
|
||||||
|
elif idx == 1:
|
||||||
|
link, headers = scrape_gofile(best)
|
||||||
|
return link, headers
|
||||||
|
elif idx == 2:
|
||||||
|
scrape_vikingfile(best)
|
||||||
|
return None, None
|
||||||
|
elif idx == 3:
|
||||||
|
scrape_megadb(best)
|
||||||
|
return None, None
|
||||||
|
else:
|
||||||
|
consoleLog("SteamRip: Unknown host, launching browser...")
|
||||||
|
webbrowser.open(best)
|
||||||
|
return None, None
|
||||||
|
except Exception as e:
|
||||||
|
consoleLog(f"SteamRip: Scraper failed - {e}")
|
||||||
return None, None
|
return None, None
|
||||||
|
|
||||||
def search(self, query: str):
|
def search(self, query: str):
|
||||||
|
|||||||
Reference in New Issue
Block a user