-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cb392ba
commit e2c8f5d
Showing
3 changed files
with
49 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
from .downloader import download_video, download_audio |
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,37 @@ | ||
import requests | ||
|
||
def download_video(url): | ||
link = f"https://ytdl.tiodevhost.my.id/?url={url}&filter=audioandvideo&quality=highestvideo&contenttype=video/mp4" | ||
response = requests.get(link) | ||
# Überprüfen Sie, ob die Anforderung erfolgreich war | ||
if response.status_code == 200: | ||
# Verarbeiten Sie den Inhalt der Antwort | ||
file_size = int(response.headers.get("Content-Length")) | ||
file_name = url.split("/")[-1] + ".mp4" | ||
|
||
# Öffnen Sie eine Datei zum Schreiben im Binary-Modus | ||
with open(file_name, "wb") as f: | ||
# Schreiben Sie den Inhalt der Antwort in die Datei | ||
f.write(response.content) | ||
|
||
print(f"Successfully downloaded {file_name} with size {file_size} bytes") | ||
else: | ||
print("Error downloading video") | ||
|
||
def download_audio(url): | ||
link = f"https://ytdl.tiodevhost.my.id/?url={url}&filter=audioonly&quality=highestaudio&contenttype=audio/mpeg" | ||
response = requests.get(link) | ||
# Überprüfen Sie, ob die Anforderung erfolgreich war | ||
if response.status_code == 200: | ||
# Verarbeiten Sie den Inhalt der Antwort | ||
file_size = int(response.headers.get("Content-Length")) | ||
file_name = url.split("/")[-1] + ".mp3" | ||
|
||
# Öffnen Sie eine Datei zum Schreiben im Binary-Modus | ||
with open(file_name, "wb") as f: | ||
# Schreiben Sie den Inhalt der Antwort in die Datei | ||
f.write(response.content) | ||
|
||
print(f"Successfully downloaded {file_name} with size {file_size} bytes") | ||
else: | ||
print("Error downloading audio") |
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,11 @@ | ||
from setuptools import setup | ||
|
||
setup(name='Pitgamers_ytdl', | ||
version='0.1', | ||
description='A YouTube downloader module', | ||
url='http://github.com/PitGamer1909/Pitgamers_ytdl', | ||
author='Nico Pit', | ||
author_email='[email protected]', | ||
license='MIT', | ||
packages=['Pitgamers_ytdl'], | ||
zip_safe=False) |