-
-
Save Rockheung/1795e60371a34c296ff714070d3d4883 to your computer and use it in GitHub Desktop.
afreeca download script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests, shutil, os | |
from time import sleep | |
URL = {1:'http://211.110.86.210/video/_definst_/smil:mvod/20181116/998/F764D250_208789998_{}.smil/media_b4000000_t64b3JpZ2luYWw=_{}.ts', | |
2:'http://101.79.136.27/video/_definst_/smil:mvod/20181116/998/B38B6850_208789998_{}.smil/media_b4000000_t64b3JpZ2luYWw=_{}.ts', | |
3:'http://101.79.136.27/video/_definst_/smil:mvod/20181116/998/1744DC8E_208789998_{}.smil/media_b4000000_t64b3JpZ2luYWw=_{}.ts', | |
} | |
DownFolder = '38699638' | |
try : | |
j, i = max([tuple(map(int, os.path.splitext(x)[0].split('_')[1:])) for x in os.listdir(DownFolder) if os.path.splitext(x)[1] == '.ts']) | |
except ValueError: | |
j, i = 1, 0 | |
while 1: | |
r = requests.get(URL[j].format(j,i), stream=True) | |
if r.status_code == 200: | |
with open('/'.join([DownFolder,'m_{}_{}.ts'.format(j,i)]), 'wb') as ts: | |
r.raw.decode_content = True | |
shutil.copyfileobj(r.raw, ts) | |
print('{} file{} in {} step{} saved.'.format(i, ('s' if i > 0 else ''), j, ('s' if j > 0 else ''))) | |
i += 1 | |
sleep(0.3) | |
elif r.status_code == 404: | |
print('>>>>> {} set{} saved.'.format(j, ('s' if j > 0 else ''))) | |
j += 1 | |
i = 0 | |
sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment