-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.py
136 lines (106 loc) · 3.51 KB
/
install.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
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# Copyright (c) 2019 bugnofix. Under MIT License.
import os, re, glob, shutil, zipfile, time, sys
# Controllo le libreria mancanti e le installo
try:
try:
import requests
except:
os.system('pip install requests')
import requests
try:
import cfscrape
except:
os.system('pip install cfscrape')
import cfscrape
module = True
except:
module = False
def youtube_dl():
print('download youtube-dl..')
url = 'https://yt-dl.org/downloads/2019.08.13/youtube-dl.exe'
r = requests.get(url)
# Scarico l'eseguibile youtube-dl
with open(r'exe\\youtube-dl.exe', 'wb') as f:
f.write(r.content)
# Aggiorno youtube-dl
os.system('exe\\youtube-dl.exe -U')
def phantom_js():
print('download phantom-js..')
url = 'https://phantomjs.org/download.html'
page = requests.get(url).text
# Cerco l'ultima versione di phantom-js
r = re.search(r'<a href="(.*)">phantomjs.*windows\.zip<\/a>', str(page), re.IGNORECASE).group(1)
file = requests.get(r)
# Scarico il file zip di phantom-js
with open(r'temp.zip', 'wb') as f:
f.write(file.content)
# Estraggo il file zip
with zipfile.ZipFile('temp.zip', 'r') as zip_ref:
zip_ref.extractall('temp1')
lista = glob.glob('temp1/phantomjs-*-windows/bin/phantomjs.exe')
for dire in lista:
os.rename(dire, 'exe\\phantomjs.exe')
# Elimino i file inutili
os.remove('temp.zip')
shutil.rmtree('temp1')
def ffmpeg_ffprobe():
print('download FFmpeg e FFprobe..')
url = 'https://ffmpeg.zeranoe.com/builds/win64/static/'
page = requests.get(url).text
# Cerco l'ultima versione di ffmpeg
r = re.search(r'<a href="(ffmpeg-.*-win64-static\.zip)" title="ffmpeg-.*-static\.zip">', str(page), re.IGNORECASE).group(1)
file = requests.get(url + r)
# Scarico il file zip
with open(r'temp.zip', 'wb') as f:
f.write(file.content)
with zipfile.ZipFile('temp.zip', 'r') as zip_ref:
zip_ref.extractall('temp1')
# Cerco ffmpeg e lo inserisco nella cartella exe
if not os.path.isfile('./ffmpeg.exe'):
lista = glob.glob('temp1/ffmpeg-*-win64-static/bin/ffmpeg.exe')
for dire in lista:
os.rename(dire, 'exe\\ffmpeg.exe')
# Cerco ffprobe e lo inserisco nella cartella exe
if not os.path.isfile('./ffprobe.exe'):
lista = glob.glob('temp1/ffmpeg-*-win64-static/bin/ffprobe.exe')
for dire in lista:
os.rename(dire, 'exe\\ffprobe.exe')
# Elimino i file inutili
os.remove('temp.zip')
shutil.rmtree('temp1')
if __name__ == '__main__':
# Variabili
ok = '[\033[1;32;40mok\033[1;37;40m] '
non_ok = '[\033[1;31;40mX\033[1;37;40m] '
# Controllo se i moduli sono stati instalalti correttamente
os.system('cls')
if module:
print(ok + 'I moduli sono installati')
else:
print(non_ok + 'I moduli non sono installati')
# Creo la directory exe
if not os.path.exists('./exe'):
os.system('mkdir exe')
# Installo youtube-dl
try:
if not os.path.isfile('./youtube-dl.exe'):
youtube_dl()
print(ok + "Youtube-dl è installato")
except:
print(non_ok + 'Youtube-dl non è installato')
# Installo phantomjs
try:
if not os.path.isfile('./phantomjs.exe'):
phantom_js()
print(ok + "Phantom-js è installato")
except:
print(non_ok + 'Phantom-js non è installato')
# Installo ffmpeg e ffprobe
try:
if not os.path.isfile('./ffmpeg.exe') or not os.path.isfile('./ffprobe.exe'):
ffmpeg_ffprobe()
print(ok + "FFmpeg è FFprobe sono installati")
except:
print(non_ok + 'FFmpeg è FFprobe non sono installati')