-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/seed completed downloads #1223
Open
Hachi-R
wants to merge
32
commits into
main
Choose a base branch
from
feature/seed-completed-downloads
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
21ca26d
feat: update schema with seeding columns
Hachi-R 9c9c0e6
feat: seed after doenload
Hachi-R c556a00
feat: get seed status
Hachi-R b32952f
feat: add ablity to pause and resume the seeding process
Hachi-R 94b65c0
lint
Hachi-R 7c039ea
feat: add seeding management logic
Hachi-R 5078946
refactor: change logic to seed new downloads
Hachi-R c314c39
feat: add option to disable seeding after download completes
Hachi-R 8ec52bf
temp
Hachi-R 5668794
feat: display upload speed during seeding
Hachi-R 9619578
lint
Hachi-R 518d919
feat: add locale strings
Hachi-R f66bdd7
feat: pause seeding before deleting game
Hachi-R 610b6e5
Merge branch 'main' into feature/seed-completed-downloads
thegrannychaseroperation 1416cd4
feat: seed downloads from previous versions
Hachi-R a7b8018
"feat: pause seeding if game folder is deleted"
Hachi-R 40ec773
lint
Hachi-R 2c1c3e3
feat: add dropdown menu component
Hachi-R ca953de
lint
Hachi-R 94ef167
feat: add menu with download options on download page
Hachi-R 9d1c04d
refactor: export with component definition
Hachi-R 3303413
lint
Hachi-R 130c236
Merge branch 'main' into feature/seed-completed-downloads
Hachi-R f2cc20c
refactor: removed dropdown title because its ugly
Hachi-R f35c34f
fix: fixing bottom panel scss
thegrannychaseroperation 6259cf4
Merge branch 'main' of github.com:hydralauncher/hydra into feature/se…
thegrannychaseroperation 2d8b63c
Merge branch 'feature/seed-completed-downloads' of github.com:hydrala…
thegrannychaseroperation 4060f7a
feat: adding aria2c
thegrannychaseroperation fe8f962
feat: adding aria2c
thegrannychaseroperation a847f93
feat: adding aria2c
thegrannychaseroperation c6d4b65
feat: adding aria2c
thegrannychaseroperation d7e06d6
feat: adding aria2c
thegrannychaseroperation File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
MAIN_VITE_API_URL=API_URL | ||
MAIN_VITE_AUTH_URL=AUTH_URL | ||
MAIN_VITE_STEAMGRIDDB_API_KEY=YOUR_API_KEY | ||
RENDERER_VITE_INTERCOM_APP_ID=YOUR_APP_ID |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import aria2p | ||
|
||
class HttpDownloader: | ||
def __init__(self): | ||
self.download = None | ||
self.aria2 = aria2p.API( | ||
aria2p.Client( | ||
host="http://localhost", | ||
port=6800, | ||
secret="" | ||
) | ||
) | ||
|
||
def start_download(self, url: str, save_path: str, header: str): | ||
if self.download: | ||
self.aria2.resume([self.download]) | ||
else: | ||
downloads = self.aria2.add(url, options={"header": header, "dir": save_path}) | ||
self.download = downloads[0] | ||
|
||
def pause_download(self): | ||
if self.download: | ||
self.aria2.pause([self.download]) | ||
|
||
def cancel_download(self): | ||
if self.download: | ||
self.aria2.remove([self.download]) | ||
self.download = None | ||
|
||
def get_download_status(self): | ||
if self.download == None: | ||
return None | ||
|
||
download = self.aria2.get_download(self.download.gid) | ||
|
||
response = { | ||
'folderName': str(download.dir) + "/" + download.name, | ||
'fileSize': download.total_length, | ||
'progress': download.completed_length / download.total_length if download.total_length else 0, | ||
'downloadSpeed': download.download_speed, | ||
'numPeers': 0, | ||
'numSeeds': 0, | ||
'status': download.status, | ||
'bytesDownloaded': download.completed_length, | ||
} | ||
|
||
return response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
from flask import Flask, request, jsonify | ||
import sys, json, urllib.parse, psutil | ||
from torrent_downloader import TorrentDownloader | ||
from http_downloader import HttpDownloader | ||
from profile_image_processor import ProfileImageProcessor | ||
import libtorrent as lt | ||
|
||
app = Flask(__name__) | ||
|
||
# Retrieve command line arguments | ||
torrent_port = sys.argv[1] | ||
http_port = sys.argv[2] | ||
rpc_password = sys.argv[3] | ||
|
||
downloads = {} | ||
# This can be streamed down from Node | ||
downloading_game_id = -1 | ||
|
||
torrent_session = lt.session({'listen_interfaces': '0.0.0.0:{port}'.format(port=torrent_port)}) | ||
|
||
def validate_rpc_password(): | ||
"""Middleware to validate RPC password.""" | ||
header_password = request.headers.get('x-hydra-rpc-password') | ||
if header_password != rpc_password: | ||
return jsonify({"error": "Unauthorized"}), 401 | ||
|
||
@app.route("/status", methods=["GET"]) | ||
def status(): | ||
auth_error = validate_rpc_password() | ||
if auth_error: | ||
return auth_error | ||
|
||
downloader = downloads.get(downloading_game_id) | ||
if downloader: | ||
status = downloads.get(downloading_game_id).get_download_status() | ||
return jsonify(status), 200 | ||
else: | ||
return jsonify(None) | ||
|
||
@app.route("/seed-status", methods=["GET"]) | ||
def seed_status(): | ||
auth_error = validate_rpc_password() | ||
if auth_error: | ||
return auth_error | ||
|
||
status = torrent_downloader.get_seed_status() | ||
return jsonify(status), 200 | ||
|
||
@app.route("/healthcheck", methods=["GET"]) | ||
def healthcheck(): | ||
return "", 200 | ||
|
||
@app.route("/process-list", methods=["GET"]) | ||
def process_list(): | ||
auth_error = validate_rpc_password() | ||
if auth_error: | ||
return auth_error | ||
|
||
process_list = [proc.info for proc in psutil.process_iter(['exe', 'pid', 'username'])] | ||
return jsonify(process_list), 200 | ||
|
||
@app.route("/profile-image", methods=["POST"]) | ||
def profile_image(): | ||
auth_error = validate_rpc_password() | ||
if auth_error: | ||
return auth_error | ||
|
||
data = request.get_json() | ||
image_path = data.get('image_path') | ||
|
||
try: | ||
processed_image_path, mime_type = ProfileImageProcessor.process_image(image_path) | ||
return jsonify({'imagePath': processed_image_path, 'mimeType': mime_type}), 200 | ||
except Exception as e: | ||
return jsonify({"error": str(e)}), 400 | ||
|
||
@app.route("/action", methods=["POST"]) | ||
def action(): | ||
global torrent_session | ||
global downloading_game_id | ||
|
||
auth_error = validate_rpc_password() | ||
if auth_error: | ||
return auth_error | ||
|
||
data = request.get_json() | ||
action = data.get('action') | ||
game_id = data.get('game_id') | ||
|
||
print(data) | ||
|
||
if action == 'start': | ||
url = data.get('url') | ||
|
||
existing_downloader = downloads.get(game_id) | ||
|
||
if existing_downloader: | ||
# This will resume the download | ||
existing_downloader.start_download(url, data['save_path'], data.get('header')) | ||
else: | ||
if url.startswith('magnet'): | ||
torrent_downloader = TorrentDownloader(torrent_session) | ||
downloads[game_id] = torrent_downloader | ||
torrent_downloader.start_download(url, data['save_path'], "") | ||
else: | ||
http_downloader = HttpDownloader() | ||
downloads[game_id] = http_downloader | ||
http_downloader.start_download(url, data['save_path'], data.get('header')) | ||
|
||
downloading_game_id = game_id | ||
|
||
elif action == 'pause': | ||
downloader = downloads.get(game_id) | ||
if downloader: | ||
downloader.pause_download() | ||
downloading_game_id = -1 | ||
elif action == 'cancel': | ||
downloader = downloads.get(game_id) | ||
if downloader: | ||
downloader.cancel_download() | ||
|
||
# elif action == 'kill-torrent': | ||
# torrent_downloader.abort_session() | ||
# torrent_downloader = None | ||
# elif action == 'pause-seeding': | ||
# torrent_downloader.pause_seeding(game_id) | ||
# elif action == 'resume-seeding': | ||
# torrent_downloader.resume_seeding(game_id, data['url'], data['save_path']) | ||
else: | ||
return jsonify({"error": "Invalid action"}), 400 | ||
|
||
return "", 200 | ||
|
||
if __name__ == "__main__": | ||
app.run(host="0.0.0.0", port=int(http_port)) | ||
|
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Binary added to git by mistake