Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # author : alfianokt
- # date : 20/06/2019
- # name : sfiledw
- # desc : download file di sfile.mobi lewat cli
- # git : https://github.com/alfianokt/sfiledw
- # mod by : fauzie811
- import os, sys
- from tqdm import tqdm
- from requests import *
- s = Session()
- # fungsi ini untuk mengambil nilai tengah
- def spliter(va, vb, vc):
- vd = vc.split(va)[1]
- vd = vd.split(vb)[0]
- return vd
- def sfileGrab(url):
- # setting custom headers
- headers = {
- 'Host':'sfile.mobi',
- 'User-Agent':'MohGila',
- 'Referer': url,
- 'Connection':'keep-alive',
- 'Upgrade-Insecure-Requests':'1',
- 'dnt':'1',
- 'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
- 'Accept-Language':'id-ID,en-US;q=0.8',
- 'X-Requested-With':'com.android.chrome'
- }
- page = s.get(url, headers=headers)
- href = spliter('id="download" href="', '" onclick', page.text)+'&k=6'
- title = sfileGrabTitle(href)
- file = s.get(href, headers=headers,stream=True)
- file_size = int(file.headers.get('content-length', 0))
- with open(title, 'wb') as fd:
- print('\rDownloading ' + href)
- cols = os.popen('stty size', 'r').read().split()[1]
- pbar = tqdm(total=file_size, unit='B', unit_scale=True, ncols=int(cols))
- for chunk in file.iter_content(1024):
- fd.write(chunk)
- pbar.update(1024)
- pbar.close()
- return 'Successfully downloaded ' + title
- def sfileGrabTitle(url):
- title = url.split('/')[7]
- title = title.split('&is=')[0]
- return title
- os.system('clear')
- print('''
- _____ _____ ____ _ ___ ___ _ ____ __ __
- / ___/| |l j| T / _] | \ | T | \| T T
- ( \_ | __j | T | | / [_ _____ | \ | | | o ) | |
- \__ T| l_ | | | l___ Y _] || D Y| l___ | _/| ~ |
- / \ || _] | | | T| [_l_____j| || T __ | | l___, |
- \ || T j l | || T | || || T| | | !
- \___jl__j |____jl_____jl_____j l_____jl_____jl__jl__j l____/
- sfile.mobi downloader
- Author: https://github.com/alfianokt | Mod by: fauzie811
- ''')
- try:
- url = input('sfile.mobi URL: ')
- if(url != ''):
- print('Parsing URL...')
- print(sfileGrab(url))
- except KeyboardInterrupt:
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment