This repository was archived by the owner on Jul 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmacytclip.py
More file actions
109 lines (84 loc) · 4.9 KB
/
Copy pathmacytclip.py
File metadata and controls
109 lines (84 loc) · 4.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
from klaxon import klaxon
import youtube_dl
import rumps
import clipboard
import os
import json
# Author: MasterMax13124
# Date: 12.Mar 2021
# Notes: Proof of concept completed. Rumps notifications seem broken, so I am using klaxon
# To-Do: Expand download options, add better icon and config options
class macytclipapp():
def __init__(self):
self.app = rumps.App("MacYTclip", "⤓")
self.title_entry = rumps.MenuItem(title="macytclip v1.1", callback=None)
self.download_h264 = rumps.MenuItem(title="Download video (H.264)", callback=self.download_h264_function)
self.download_dnxhr25fps = rumps.MenuItem(title="Download video (DNxHR 25FPS)", callback=self.download_dnxhr25fps_function)
self.download_mp3 = rumps.MenuItem(title="Download audio (MP3)", callback=self.download_mp3_function)
self.download_wav = rumps.MenuItem(title="Download audio (WAV)", callback=self.download_wav_function)
self.app.menu = [self.title_entry, self.download_h264, self.download_dnxhr25fps, self.download_mp3, self.download_wav]
def download_h264_function(self, sender):
klaxon("Download started", "macytclip", "")
ydl_opts = {'format' : 'bestvideo+bestaudio[ext=m4a]/best','outtmpl': 'macytclipvideo','writeinfojson': 'true', 'merge_output_format': 'mp4', 'nocheckcertificate': 'true'}
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([clipboard.paste()])
with open('macytclipvideo.info.json') as json_file:
data = json.load(json_file)
os.rename("macytclipvideo.mp4", data["fulltitle"] + ".mp4")
os.remove("macytclipvideo.info.json")
klaxon("Check your Downloads folder!", "macytclip", "Download completed successfully")
except:
klaxon("The copied text was not a valid url!", "macytclip")
def download_dnxhr25fps_function(self, sender):
klaxon("Download started", "macytclip", "")
ydl_opts = {'format': 'bestvideo+bestaudio', 'outtmpl': 'macytclipvideo', 'writeinfojson': 'true', 'no-check-certificate': 'true'}
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([clipboard.paste()])
#line below is the original command from Wolfgangs powershell script
#ffmpeg -i video.mp4 -c:v dnxhd -profile:v dnxhr_hq -vf fps=25/1,format=yuv422p -c:a pcm_s16le video.mov && rm video.mp4
os.system("ffmpeg -i macytclipvideo.mp4 -c:v dnxhd -profile:v dnxhr_hq -vf fps=25/1,format=yuv422p -c:a pcm_s16le macytclipvideo.mov && rm macytclipvideo.mp4")
with open('macytclipvideo.info.json') as json_file:
data = json.load(json_file)
os.rename("macytclipvideo.mov", data["fulltitle"] + ".mov")
os.remove("macytclipvideo.info.json")
klaxon("Check your Downloads folder!", "macytclip", "Download completed successfully")
except:
klaxon("The copied text was not a valid url!", "macytclip")
def download_mp3_function(self, sender):
klaxon("Download started", "macytclip", "")
#adjust for mp3:'--no-playlist' '--continue' '-f bestaudio' -x --audio-format mp3 '--no-check-certificate'
ydl_opts = {'format' : 'bestaudio[ext=m4a]/best','outtmpl': 'macytclipvideo','writeinfojson': 'true', 'merge_output_format': 'mp3', 'nocheckcertificate': 'true'}
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([clipboard.paste()])
with open('macytclipvideo.info.json') as json_file:
data = json.load(json_file)
os.rename("macytclipvideo", data["fulltitle"] + ".mp3")
os.remove("macytclipvideo.info.json")
klaxon("Check your Downloads folder!", "macytclip", "Download completed successfully")
except:
klaxon("The copied text was not a valid url!", "macytclip")
pass
def download_wav_function(self, sender):
klaxon("Download started", "macytclip", "")
ydl_opts = {'format' : 'bestaudio[ext=m4a]/best','outtmpl': 'macytclipvideo','writeinfojson': 'true', 'merge_output_format': 'wav', 'nocheckcertificate': 'true'}
try:
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([clipboard.paste()])
with open('macytclipvideo.info.json') as json_file:
data = json.load(json_file)
os.rename("macytclipvideo", data["fulltitle"] + ".wav")
os.remove("macytclipvideo.info.json")
klaxon("Check your Downloads folder!", "macytclip", "Download completed successfully")
except:
klaxon("The copied text was not a valid url!", "macytclip")
pass
def run(self):
self.app.run()
if __name__ == '__main__':
os.chdir(os.path.expanduser('~'))
os.chdir('Downloads')
app = macytclipapp()
app.run()