Compare commits
No commits in common. "master" and "issue#1" have entirely different histories.
29
download.py
29
download.py
@ -1,11 +1,4 @@
|
|||||||
try:
|
import yt_dlp as yt
|
||||||
import yt_dlp as yt
|
|
||||||
from plyer import notification
|
|
||||||
except:
|
|
||||||
import os
|
|
||||||
script_dir = os.path.dirname(os.path.realpath(__file__))
|
|
||||||
print("Please install dependances.\n" +
|
|
||||||
"This can be done with the command 'pip3 install -r " + script_dir + "/requierments.txt'")
|
|
||||||
|
|
||||||
def get(yt_url):
|
def get(yt_url):
|
||||||
ytdl_options = {
|
ytdl_options = {
|
||||||
@ -19,25 +12,17 @@ def get(yt_url):
|
|||||||
'embed_metadata': True,
|
'embed_metadata': True,
|
||||||
'format': 'any/bestaudio/best',
|
'format': 'any/bestaudio/best',
|
||||||
# ℹ️ See help(yt_dlp.postprocessor) for a list of available Postprocessors and their arguments
|
# ℹ️ See help(yt_dlp.postprocessor) for a list of available Postprocessors and their arguments
|
||||||
'postprocessors': [{ # Extract audio using ffmpeg,
|
'postprocessors': [{ # Extract audio using ffmpeg
|
||||||
|
'key': 'FFmpegMetadata'
|
||||||
|
},{
|
||||||
'key': 'FFmpegExtractAudio',
|
'key': 'FFmpegExtractAudio',
|
||||||
'preferredcodec': 'mp3',
|
'preferredcodec': 'mp3',
|
||||||
},{'key': 'FFmpegMetadata'},
|
|
||||||
{'key': 'EmbedThumbnail'},]
|
}]
|
||||||
}
|
}
|
||||||
|
|
||||||
with yt.YoutubeDL(ytdl_options) as ytdl:
|
with yt.YoutubeDL(ytdl_options) as ytdl:
|
||||||
ytdl.download(yt_url)
|
ytdl.download(yt_url)
|
||||||
try:
|
|
||||||
notification.notify(
|
|
||||||
title = "yt2mp3",
|
|
||||||
message = "Download and conversion complete.",
|
|
||||||
app_icon = None,
|
|
||||||
timeout = 3,
|
|
||||||
)
|
|
||||||
except:
|
|
||||||
print("Notification failed.")
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def dl_progress(d):
|
def dl_progress(d):
|
||||||
|
@ -1,2 +1 @@
|
|||||||
yt-dlp
|
yt-dlp
|
||||||
plyer
|
|
@ -9,7 +9,7 @@ help_epilog = ("This script is very dependent on yt-dlp.\n"+
|
|||||||
|
|
||||||
cmd_option_set = argparse.ArgumentParser(description='Backup YouTube channels.', epilog=help_epilog)
|
cmd_option_set = argparse.ArgumentParser(description='Backup YouTube channels.', epilog=help_epilog)
|
||||||
cmd_option_set.add_argument('--version', '-v', dest='print_version', action='store_true', help='Print the current version number.')
|
cmd_option_set.add_argument('--version', '-v', dest='print_version', action='store_true', help='Print the current version number.')
|
||||||
cmd_option_set.add_argument(dest='url_to_convert', default='', metavar="YT URL", nargs=argparse.REMAINDER, help="The URL of the YouTube video you're converting to a local mp3.")
|
cmd_option_set.add_argument(dest='url_to_convert', help="The URL of the YouTube video you're converting to a local mp3.")
|
||||||
cmd_options = cmd_option_set.parse_args()
|
cmd_options = cmd_option_set.parse_args()
|
||||||
|
|
||||||
if (cmd_options.print_version):
|
if (cmd_options.print_version):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user