commit f7477a46565aec435e97971aa849658756a9b92d Author: Ethan J. Hadley Date: Sat Sep 5 15:27:30 2026 -0600 Downloaded m4as diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a306afb --- /dev/null +++ b/.gitignore @@ -0,0 +1,14 @@ +.venv/ +*.pyc +__pycache__/ +instance/ +.cache/ +.pytest_cache/ +.coverage +htmlcov/ +dist/ +build/ +*.egg-info/ +.idea/ +*.swp +*~ diff --git a/happy_ripper.py b/happy_ripper.py new file mode 100644 index 0000000..02a0a89 --- /dev/null +++ b/happy_ripper.py @@ -0,0 +1,65 @@ +from flask import Flask, render_template, request, jsonify +from threading import Thread +import time +from yt_dlp import YoutubeDL +from yt_dlp.utils import DownloadError +import pathlib +import os +import shutil + + +def rip_worker(rip_queue: list[str]): + project_root_path = pathlib.Path(__file__).parent.resolve() + tmp_path = f"{project_root_path}/tmp" + + while True: + queue_is_empty = len(rip_queue) == 0 + if queue_is_empty: + continue + + # Creates tmp directory, if it already exists, it clears it, and makes a new one. + if not os.path.isdir(tmp_path): + os.mkdir(tmp_path) + else: + shutil.rmtree(tmp_path) + os.mkdir(tmp_path) + + current_url = rip_queue[0] + + try: + with YoutubeDL( + { + "format": "m4a/bestaudio/best", + "postprocessors": [ + { + "key": "FFmpegExtractAudio", + "preferredcodec": "m4a", + } + ], + "outtmpl": f"{tmp_path}/%(title)s.%(ext)s", + } + ) as ydl: + error_code = ydl.download([current_url]) + + except DownloadError: + print("Download Error") + + rip_queue.pop(0) + time.sleep(1) + + +app = Flask(__name__) +rip_queue = [] +ripping_thread = Thread(target=rip_worker, args=(rip_queue,), daemon=True).start() + + +@app.route("/") +def index(): + return render_template("index.html") + + +@app.route("/rip", methods=["POST"]) +def rip(): + url = request.form.get("url") + rip_queue.append(url) + return jsonify({"success": True, "message": f"Added, {url}!"}) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..d5d3d8f --- /dev/null +++ b/templates/index.html @@ -0,0 +1,55 @@ + + + + + + Happy Ripper + + + + +
+

Request

+
+
+ +
+ +
+
+ + + + + diff --git a/tmp/Can't Stand Losing You.m4a b/tmp/Can't Stand Losing You.m4a new file mode 100644 index 0000000..b793fda Binary files /dev/null and b/tmp/Can't Stand Losing You.m4a differ diff --git a/tmp/De Do Do Do, De Da Da Da.m4a b/tmp/De Do Do Do, De Da Da Da.m4a new file mode 100644 index 0000000..71011a0 Binary files /dev/null and b/tmp/De Do Do Do, De Da Da Da.m4a differ diff --git a/tmp/Don't Stand So Close To Me.m4a b/tmp/Don't Stand So Close To Me.m4a new file mode 100644 index 0000000..7f0d8c5 Binary files /dev/null and b/tmp/Don't Stand So Close To Me.m4a differ diff --git a/tmp/Every Breath You Take.m4a b/tmp/Every Breath You Take.m4a new file mode 100644 index 0000000..aa8359f Binary files /dev/null and b/tmp/Every Breath You Take.m4a differ diff --git a/tmp/Every Little Thing She Does Is Magic.m4a b/tmp/Every Little Thing She Does Is Magic.m4a new file mode 100644 index 0000000..c24f0fc Binary files /dev/null and b/tmp/Every Little Thing She Does Is Magic.m4a differ diff --git a/tmp/Invisible Sun.m4a b/tmp/Invisible Sun.m4a new file mode 100644 index 0000000..0954ea8 Binary files /dev/null and b/tmp/Invisible Sun.m4a differ diff --git a/tmp/King Of Pain.m4a b/tmp/King Of Pain.m4a new file mode 100644 index 0000000..c4cd2b6 Binary files /dev/null and b/tmp/King Of Pain.m4a differ diff --git a/tmp/Message In A Bottle.m4a b/tmp/Message In A Bottle.m4a new file mode 100644 index 0000000..f279f75 Binary files /dev/null and b/tmp/Message In A Bottle.m4a differ diff --git a/tmp/Roxanne.m4a b/tmp/Roxanne.m4a new file mode 100644 index 0000000..b45e8b1 Binary files /dev/null and b/tmp/Roxanne.m4a differ diff --git a/tmp/So Lonely.m4a b/tmp/So Lonely.m4a new file mode 100644 index 0000000..2069798 Binary files /dev/null and b/tmp/So Lonely.m4a differ diff --git a/tmp/Spirits In The Material World.m4a b/tmp/Spirits In The Material World.m4a new file mode 100644 index 0000000..d8a20c8 Binary files /dev/null and b/tmp/Spirits In The Material World.m4a differ diff --git a/tmp/Synchronicity II.m4a b/tmp/Synchronicity II.m4a new file mode 100644 index 0000000..8f47946 Binary files /dev/null and b/tmp/Synchronicity II.m4a differ diff --git a/tmp/Tea In The Sahara.m4a b/tmp/Tea In The Sahara.m4a new file mode 100644 index 0000000..d68cd58 Binary files /dev/null and b/tmp/Tea In The Sahara.m4a differ diff --git a/tmp/The Bed's Too Big Without You.m4a b/tmp/The Bed's Too Big Without You.m4a new file mode 100644 index 0000000..ca30259 Binary files /dev/null and b/tmp/The Bed's Too Big Without You.m4a differ diff --git a/tmp/Walking On The Moon.m4a b/tmp/Walking On The Moon.m4a new file mode 100644 index 0000000..1d31663 Binary files /dev/null and b/tmp/Walking On The Moon.m4a differ diff --git a/tmp/Wrapped Around Your Finger.m4a b/tmp/Wrapped Around Your Finger.m4a new file mode 100644 index 0000000..d81d834 Binary files /dev/null and b/tmp/Wrapped Around Your Finger.m4a differ