forked from lovegaoshi/bili-music-segmenter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
biliupinit.py
28 lines (26 loc) · 1000 Bytes
/
biliupinit.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
import subprocess
import tarfile
import glob
import os
import requests
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description='ina music segment')
parser.add_argument(
'--system', type=str, default=r'x86_64-linux-musl.tar.xz',
)
parser.add_argument(
'--sudocp', default=False, action='store_true'
)
args = parser.parse_args()
req = requests.get('https://api.github.com/repositories/437055168/releases/latest').json()
targeted_download = list(filter(lambda x: args.system in x['name'], req['assets']))[0]
subprocess.call(['wget', targeted_download['browser_download_url']])
biliup_tar_path = glob.glob('biliupR*')[0]
tarfile.open(biliup_tar_path).extractall()
os.remove(biliup_tar_path)
for file in glob.glob('biliupR*/*'):
if args.sudocp:
subprocess.call(['sudo', 'mv', file, '/bin'])
else:
os.rename(file, os.path.join('/bin', os.path.basename(file)))