mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
download is in download.py, needs to move
This commit is contained in:
@@ -35,7 +35,7 @@ def _get_telegram_posts():
|
|||||||
|
|
||||||
for bubble in bubbles:
|
for bubble in bubbles:
|
||||||
post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text")
|
post_txt = bubble.find("div", class_="tgme_widget_message_text js-message_text")
|
||||||
if not post_txt or not post_txt.b:
|
if not post_txt is None or not post_txt.b is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
title = post_txt.b.text
|
title = post_txt.b.text
|
||||||
@@ -75,13 +75,14 @@ def scrape_m0nkrus(query):
|
|||||||
|
|
||||||
def get_magnet(post: Dict):
|
def get_magnet(post: Dict):
|
||||||
_, post_links, _, _, _ = format_data([post])
|
_, post_links, _, _, _ = format_data([post])
|
||||||
return post_links[0]
|
return get_magnet_link(post_links[0])
|
||||||
|
|
||||||
Metadata = {
|
Metadata = {
|
||||||
"name" : "m0nkrus",
|
"name" : "m0nkrus",
|
||||||
"headers" : ["Post Title", "Author"],
|
"headers" : ["Post Title", "Author"],
|
||||||
"scrapeFunc" : scrape_m0nkrus,
|
"scrapeFunc" : scrape_m0nkrus,
|
||||||
""
|
"linkFunc" : get_magnet,
|
||||||
|
"isMagnet" : True,
|
||||||
}
|
}
|
||||||
|
|
||||||
def init_m0nkrus():
|
def init_m0nkrus():
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
|
from core.utils.logging.loghandler import consoleLog
|
||||||
|
|
||||||
def scrape_gofile(url):
|
def scrape_gofile(url):
|
||||||
|
|
||||||
@@ -18,13 +19,12 @@ def scrape_gofile(url):
|
|||||||
f"https://api.gofile.io/contents/{filetoken}",
|
f"https://api.gofile.io/contents/{filetoken}",
|
||||||
headers=headers,
|
headers=headers,
|
||||||
)
|
)
|
||||||
|
try:
|
||||||
|
|
||||||
temp: dict = r.json()["data"]["children"]
|
temp: dict = r.json()["data"]["children"]
|
||||||
child = [key for key in temp.keys()]
|
child = [key for key in temp.keys()]
|
||||||
|
|
||||||
|
return temp[child[0]]["link"]
|
||||||
|
except:
|
||||||
|
consoleLog("gofile didnt auth you, either the api has changed\n or you sent to many requests, please try again later.\n If it still doesnt work please open an issue on Github.")
|
||||||
|
|
||||||
return temp[child[0]]["link"]
|
|
||||||
|
|
||||||
|
|
||||||
out = scrape_gofile("https://gofile.io/d/tvvzAD")
|
|
||||||
print(out)
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import requests
|
import requests
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
|
from core.utils.data.tracker import get_magnet_link
|
||||||
from core.utils.network.jsonhandler import split_data, format_data
|
from core.utils.network.jsonhandler import split_data, format_data
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
@@ -30,15 +31,15 @@ def scrape_rutracker(query):
|
|||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
def get_magnet_link(post: Dict):
|
def get_magnet(post: Dict):
|
||||||
_, post_links, _, _, _ = format_data([post])
|
_, post_links, _, _, _ = format_data([post])
|
||||||
return post_links[0]
|
return get_magnet_link(post_links[0])
|
||||||
|
|
||||||
Metadata = {
|
Metadata = {
|
||||||
"name" : "rutracker",
|
"name" : "rutracker",
|
||||||
"headers" : ["Post Title", "Author", "Seeders", "Leechers"],
|
"headers" : ["Post Title", "Author", "Seeders", "Leechers"],
|
||||||
"scrapeFunc" : scrape_rutracker,
|
"scrapeFunc" : scrape_rutracker,
|
||||||
"linkFunc" : get_magnet_link,
|
"linkFunc" : get_magnet,
|
||||||
"isMagnet" : True,
|
"isMagnet" : True,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
|
|
||||||
import os
|
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from fuzzyfinder.main import fuzzyfinder
|
from fuzzyfinder.main import fuzzyfinder
|
||||||
import requests
|
import requests
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import webbrowser
|
import webbrowser
|
||||||
from typing import Generator
|
from core.data.scrapers.provider.buzzheavier import scrape_buzzheavier
|
||||||
|
from core.data.scrapers.provider.gofile import scrape_gofile
|
||||||
|
from typing import Generator, Dict
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
|
|
||||||
@@ -94,12 +95,14 @@ def get_download_link(post: Dict):
|
|||||||
links = scrape_steamrip_game_downloads(url)
|
links = scrape_steamrip_game_downloads(url)
|
||||||
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) < 2:
|
if links.index(best) == 0:
|
||||||
return best
|
return scrape_buzzheavier(best)
|
||||||
|
elif links.index(best) == 1:
|
||||||
|
return scrape_gofile(best)
|
||||||
else:
|
else:
|
||||||
consoleLog("cant scrape this cuz of captcha... opening in the browser")
|
consoleLog("cant scrape this cuz of captcha... opening in the browser")
|
||||||
webbrowser.open(best)
|
webbrowser.open(best)
|
||||||
@@ -118,6 +121,8 @@ Metadata = {
|
|||||||
"name" : "steamrip",
|
"name" : "steamrip",
|
||||||
"headers" : ["Game"],
|
"headers" : ["Game"],
|
||||||
"scrapeFunc" : filter_steamrip,
|
"scrapeFunc" : filter_steamrip,
|
||||||
|
"linkFunc" : get_download_link,
|
||||||
|
"isMagnet" : False,
|
||||||
}
|
}
|
||||||
|
|
||||||
def init_steamrip():
|
def init_steamrip():
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ from bs4 import BeautifulSoup
|
|||||||
from urllib.parse import urljoin
|
from urllib.parse import urljoin
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from core.utils.data.tracker import get_magnet_link
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
|
|
||||||
|
|
||||||
@@ -39,16 +40,17 @@ def scrape_uztracker(query):
|
|||||||
consoleLog(f"Failed to fetch {search_url}: {e}")
|
consoleLog(f"Failed to fetch {search_url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def get_magnet(post: Dict):
|
||||||
|
item = "https://uztracker.net/" + post["url"].lstrip("./")
|
||||||
|
return get_magnet_link(item)
|
||||||
|
|
||||||
Metadata = {
|
Metadata = {
|
||||||
"name" : "uztracker",
|
"name" : "uztracker",
|
||||||
"headers" : ["Post Title", "Author"],
|
"headers" : ["Post Title", "Author"],
|
||||||
"searchkey" : None,
|
|
||||||
"scrapeFunc" : scrape_uztracker,
|
"scrapeFunc" : scrape_uztracker,
|
||||||
"scrapeSearches" : True,
|
"linkFunc" : get_magnet,
|
||||||
|
"isMagnet" : True,
|
||||||
}
|
}
|
||||||
def get_magnet_link(post: Dict):
|
|
||||||
item = "https://uztracker.net/" + post["url"].lstrip("./")
|
|
||||||
return item
|
|
||||||
|
|
||||||
def init_uztracker():
|
def init_uztracker():
|
||||||
state.trackers.update({Metadata["name"] : Metadata})
|
state.trackers.update({Metadata["name"] : Metadata})
|
||||||
|
|||||||
@@ -540,9 +540,7 @@ class MainWindow(QtWidgets.QMainWindow, QWidget):
|
|||||||
self.downloadList.setItemDelegateForColumn(0, delegate)
|
self.downloadList.setItemDelegateForColumn(0, delegate)
|
||||||
delegate.clicked.connect(on_pause_resume_clicked)
|
delegate.clicked.connect(on_pause_resume_clicked)
|
||||||
|
|
||||||
#! FIX THIS
|
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.selectedItems(),))))
|
||||||
|
|
||||||
self.dlbutton.clicked.connect(lambda: run_thread(threading.Thread(target=download_selected, args=(state.trackertable.currentItem(), state.posts))))
|
|
||||||
|
|
||||||
container.setLayout(containerLayout)
|
container.setLayout(containerLayout)
|
||||||
self.setCentralWidget(container)
|
self.setCentralWidget(container)
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
from PySide6.QtWidgets import QTableWidgetItem
|
from PySide6.QtWidgets import QTableWidgetItem
|
||||||
from core.utils.logging.logs import consoleLog
|
from core.utils.logging.logs import consoleLog
|
||||||
from core.utils.data.tracker import get_magnet_link
|
from core.network.libtorrent_wrapper import add_magnet
|
||||||
from core.network.libtorrent_wrapper import add_download
|
|
||||||
from core.utils.general.wrappers import run_thread
|
from core.utils.general.wrappers import run_thread
|
||||||
from core.utils.logging.logs import add_download_log
|
from core.utils.logging.logs import add_download_log
|
||||||
from core.network.libtorrent_int import add_seed
|
from core.network.libtorrent_int import add_seed
|
||||||
from core.utils.data.state import state
|
from core.utils.data.state import state
|
||||||
|
from urllib.parse import urlparse, unquote
|
||||||
import threading
|
import threading
|
||||||
|
import re
|
||||||
|
import requests
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
def download_selected(items: list[QTableWidgetItem]):
|
def download_selected(items: list[QTableWidgetItem]):
|
||||||
@@ -21,19 +24,52 @@ def download_selected(items: list[QTableWidgetItem]):
|
|||||||
if text != "" and text not in seen:
|
if text != "" and text not in seen:
|
||||||
seen.add(text)
|
seen.add(text)
|
||||||
consoleLog(f"Downloading {text}")
|
consoleLog(f"Downloading {text}")
|
||||||
run_thread(threading.Thread(target=run_download, args=(text, state.posts[item.row()])))
|
run_thread(threading.Thread(target=run_download, args=(state.posts[item.row()],)))
|
||||||
|
|
||||||
def run_download(item, posts, post_titles):
|
def get_direct_filename(url: str, headers) -> str:
|
||||||
post_url = get_item_url(item, posts, post_titles)
|
cd = headers.get('content-disposition', '')
|
||||||
consoleLog(f"Selected URL: {post_url}")
|
if cd:
|
||||||
magnet_uri = get_magnet_link(post_url)
|
match = re.search(r'filename\*=UTF-8\'\'(.+)', cd) # RFC 5987 encoded
|
||||||
|
if match:
|
||||||
|
return unquote(match.group(1))
|
||||||
|
match = re.search(r'filename="?([^";\n]+)"?', cd)
|
||||||
|
if match:
|
||||||
|
return match.group(1).strip()
|
||||||
|
|
||||||
if add_download(magnet_uri):
|
path = urlparse(url).path
|
||||||
add_download_log(item, post_url, magnet_uri, False)
|
name = path.split('/')[-1]
|
||||||
|
if name:
|
||||||
|
return unquote(name)
|
||||||
|
|
||||||
|
return f"download{random.randint(1,9999)}" #avoid collision
|
||||||
|
|
||||||
|
def filedownload(url):
|
||||||
|
try:
|
||||||
|
with requests.get(url, stream=True, timeout=30) as r:
|
||||||
|
r.raise_for_status()
|
||||||
|
name = get_direct_filename(url, r.headers)
|
||||||
|
|
||||||
|
with open(state.download_path + f"/{name}", 'wb') as f:
|
||||||
|
for chunk in r.iter_content(chunk_size=8192):
|
||||||
|
f.write(chunk)
|
||||||
|
|
||||||
|
consoleLog(f"Finished downloading {name}")
|
||||||
|
except Exception as e:
|
||||||
|
consoleLog(f"Error downloading: {e}")
|
||||||
|
|
||||||
|
def run_download(post):
|
||||||
|
linkfunc = state.trackers[state.currenttracker]["linkFunc"]
|
||||||
|
ismagnet = state.trackers[state.currenttracker]["isMagnet"]
|
||||||
|
link = linkfunc(post)
|
||||||
|
|
||||||
|
if ismagnet:
|
||||||
|
add_magnet(link)
|
||||||
|
else:
|
||||||
|
filedownload(link)
|
||||||
|
|
||||||
def run_download_direct(magnet_uri):
|
def run_download_direct(magnet_uri):
|
||||||
consoleLog(f"Direct download: {magnet_uri[:60]}")
|
consoleLog(f"Direct download: {magnet_uri[:60]}")
|
||||||
add_download(magnet_uri)
|
add_magnet(magnet_uri)
|
||||||
add_download_log("Direct Download", "", magnet_uri, False)
|
add_download_log("Direct Download", "", magnet_uri, False)
|
||||||
|
|
||||||
def seed_magnet(magnet_uri, file_path):
|
def seed_magnet(magnet_uri, file_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user