mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-04 17:59:43 +02:00
improve structure, code cleanup and improved switching between uz & rutracker
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import requests
|
||||
|
||||
server = "https://pizzasucht.net"
|
||||
|
||||
|
||||
def scrape_rutracker(search_text):
|
||||
search = requests.get(f"{server}/search/{search_text}")
|
||||
data = search.json()
|
||||
resulttitles = data["titles"]
|
||||
resultlinks = data["links"]
|
||||
return resulttitles, resultlinks
|
||||
|
||||
|
||||
# This Function utilizes the SoftwareManager Server - Source Code can be found in the "Server" branch.
|
||||
@@ -0,0 +1,21 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
|
||||
def get_magnet_link(post_url, debug):
|
||||
try:
|
||||
response = requests.get(post_url)
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||
if magnet_link:
|
||||
if debug:
|
||||
print("Magnet Link Retrieved: ", magnet_link['href'])
|
||||
return magnet_link['href']
|
||||
else:
|
||||
if debug:
|
||||
print("Magnet Link not Found!")
|
||||
except requests.RequestException as e:
|
||||
if debug:
|
||||
print(f"Failed to fetch {post_url}: {e}")
|
||||
return None
|
||||
@@ -76,26 +76,6 @@ def get_post_title(post_url, debug):
|
||||
return None
|
||||
|
||||
|
||||
def get_magnet_link(post_url, debug):
|
||||
if up:
|
||||
try:
|
||||
response = requests.get(post_url)
|
||||
response.raise_for_status()
|
||||
soup = BeautifulSoup(response.text, 'html.parser')
|
||||
magnet_link = soup.find('a', href=lambda x: x and x.startswith('magnet:'))
|
||||
if magnet_link:
|
||||
if debug:
|
||||
print("Magnet Link Retrieved: ", magnet_link['href'])
|
||||
return magnet_link['href']
|
||||
else:
|
||||
if debug:
|
||||
print("Magnet Link not Found!")
|
||||
except requests.RequestException as e:
|
||||
if debug:
|
||||
print(f"Failed to fetch {post_url}: {e}")
|
||||
else:
|
||||
print("Error: Uztracker down")
|
||||
return None
|
||||
|
||||
# What x and x.startswith('magnet:') Does
|
||||
# x - check if x exists (not None/empty)
|
||||
|
||||
Reference in New Issue
Block a user