forked from xskylarx/SkyTube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
skytubec.py
154 lines (131 loc) · 5.78 KB
/
skytubec.py
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
__author__ = 'xskylarx'
# -*- coding: utf-8 -*-
# Python + PyQt4 By Skylar
#
# Creado: 29 - sep - 2013
# Por: xskylarx
# xskyofx@gmail.com
#
#v1.4 se a単ade compatibilidad con Mac, Windows, Linux, a hora abre el reproductor predeterminado del sistema.
#v1.3 -> se a単ade lista automatica, capturador de enlaces, lista de descargas.
#v1.2 -> se corrige Bug al recibir simbolos como " | ' <>-_:.,
#
# Por favor si modificas algo haz referencia al autor.
from pafy import Pafy
import os
import sys
try:
def sistema():
return sys.platform
if len(sys.argv) >= 1:
u = sys.argv[1]
u = str(u).replace('[','')
u = str(u).replace(']','')
u = str(u).replace("'",'')
for i in u.split(','):
url = i
if len(sys.argv) <= 2:
formato = 'mp4'
else:
formato = sys.argv[2]
video_id = url
if video_id.split('?v=') == 1:
video_id = video_id.split('?v=')
if len(video_id) == 1:
url= 'http://www.youtube.com/watch?v=' + video_id[1]
else:
url= 'http://www.youtube.com/watch?v=' + video_id
video =Pafy(url)
if 'win32' in sistema() or 'win64' in sistema():
os.system('cls')
if 'darwin' in sistema():
os.system('clear')
if 'linux' in sistema():
os.system('clear')
stream = video.getbest(preftype=formato.lower())
size = stream.get_filesize()
print(' _____ _ _____ _')
print(' / ___| | |_ _| | |')
print(' \ --.| | ___ _| |_ _| |__ ___ ')
print(" `--. \ |/ / | | | | | | | |_ \\ / _ \\")
print(' /\__/ / <| |_| | | |_| | |_) | __/')
print(' \____/|_|\_\\__, \_/\__,_|_.__/ \___|')
print(' __/ | ')
print(' |___/ V1.4')
print(" Tu Video se esta descargando ... \n\n\n '{}' [{:,} Bytes]".format(stream.filename, size))
print("-Resolucion %s; Formato: %s" % (stream.resolution, stream.extension))
print('\n')
titulo = stream.title
titulo = str(titulo).replace('.','')
titulo = str(titulo).replace('"','')
titulo = str(titulo).replace(':','')
titulo = str(titulo).replace('_','')
titulo = str(titulo).replace('-','')
titulo = str(titulo).replace(';','')
titulo = str(titulo).replace('|','')
titulo = str(titulo).replace("'",'')
titulo = str(titulo).replace("+",'')
titulo = str(titulo).replace("!",'')
titulo = str(titulo).replace("/",'')
titulo = str(titulo).replace("\\",'')
titulo = str(titulo).replace("*",'')
titulo = str(titulo).replace("#",'')
titulo = str(titulo).replace("%",'')
titulo = str(titulo).replace("&",'')
titulo = str(titulo).replace("(",'')
titulo = str(titulo).replace(")",'')
titulo = str(titulo).replace("?",'')
titulo = str(titulo).replace("多",'')
titulo = str(titulo).replace("臓",'')
titulo = str(titulo).replace("[",'')
titulo = str(titulo).replace("]",'')
titulo = str(titulo).replace("{",'')
titulo = str(titulo).replace("}",'')
titulo = str(titulo).replace("=",'')
titulo = str(titulo).replace("~",'')
titulo = str(titulo).replace("<",'')
titulo = str(titulo).replace(">",'')
if 'win32' in sistema() or 'win64' in sistema():
filename = os.path.join (os.environ['USERPROFILE'],'videos') + '\\' + titulo + '.' + stream.extension
else:
filename = os.path.join (os.environ['HOME'],'Movies') + '/' + titulo + '.' + stream.extension
stream.download(quiet=False, filepath=filename)
print('Tu video se Descargo Correctamente, lo encuentras en tu carpeta de Videos .. ')
print('Esta ventana se cerrara en 5 segundos...')
if 'win32' in sistema() or 'win64' in sistema():
os.system('ping -n 5 localhost>nul')
os.system('exit')
else:
os.system('logout')
os.system('sleep 5')
else:
if 'win32' in sistema() or 'win64' in sistema():
os.system('cls')
if 'darwin' in sistema():
os.system('clear')
if 'linux' in sistema():
os.system('clear')
print('Error en SkyTubeC, no Hay URL de Youtube')
print('')
print('Modo de uso: skytubec http://www.youtube.com/watch?v=QJO3ROT-A4E ')
if 'win32' in sistema() or 'win64' in sistema():
os.system('pause>nul')
except Exception as e:
print(' _____ _ _____ _')
print(' / ___| | |_ _| | |')
print(' \ --.| | ___ _| |_ _| |__ ___ ')
print(" `--. \ |/ / | | | | | | | |_ \\ / _ \\")
print(' /\__/ / <| |_| | | |_| | |_) | __/')
print(' \____/|_|\_\\__, \_/\__,_|_.__/ \___|')
print(' __/ | ')
print(' |___/ V1.4')
print('Hay un Error en la Direccion de Youtube: \n ' + url + '\n Por Favor Verifica..')
print('')
if 'win32' in sistema() or 'win64' in sistema():
os.system('ping -n 5 localhost')
if 'darwin' in sistema():
os.system('sleep 5')
os.system('logout')
if 'linux' in sistema():
os.system('clear')
pass