Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dc8c561576 | |||
| d6a7b56bcf | |||
| bafe53e3a5 | |||
| 5aa80c6fc9 | |||
| 35223a70b0 | |||
| 3deefbadd8 |
23
download.py
23
download.py
@@ -1,5 +1,11 @@
|
|||||||
import yt_dlp as yt
|
try:
|
||||||
from plyer import notification
|
import yt_dlp as yt
|
||||||
|
from notifypy import Notify
|
||||||
|
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 = {
|
||||||
@@ -22,12 +28,13 @@ def get(yt_url):
|
|||||||
|
|
||||||
with yt.YoutubeDL(ytdl_options) as ytdl:
|
with yt.YoutubeDL(ytdl_options) as ytdl:
|
||||||
ytdl.download(yt_url)
|
ytdl.download(yt_url)
|
||||||
notification.notify(
|
try:
|
||||||
title = "yt2mp3",
|
notification = Notify()
|
||||||
message = "Download and conversion complete.",
|
notification.title = "yt2mp3"
|
||||||
app_icon = None,
|
notification.message = "Download and conversion complete."
|
||||||
timeout = 5,
|
notification.send()
|
||||||
)
|
except:
|
||||||
|
print("Notification failed.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
yt-dlp
|
yt-dlp
|
||||||
plyer
|
notify-py
|
||||||
@@ -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', help="The URL of the YouTube video you're converting to a local mp3.")
|
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_options = cmd_option_set.parse_args()
|
cmd_options = cmd_option_set.parse_args()
|
||||||
|
|
||||||
if (cmd_options.print_version):
|
if (cmd_options.print_version):
|
||||||
|
|||||||
Reference in New Issue
Block a user