Skip to content

Instantly share code, notes, and snippets.

@devster31
Last active November 18, 2015 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devster31/c381d3ae1bf91d57698b to your computer and use it in GitHub Desktop.
Save devster31/c381d3ae1bf91d57698b to your computer and use it in GitHub Desktop.
requires html5lib, beautifulsoup4 and requests, only works with userscloud.com
https://userscloud.com/svmwe8593ehb/100th_Anniversary_Special_-_Guardians_of_the_Galaxy_01_(2014)_(digital)_(Minutemen-Faessla).cbz
https://userscloud.com/lb7fh14rhb08/Guardians_of_the_Galaxy_(FCBD_2014)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/x3qo53t7kc8a/Guardians_of_the_Galaxy_-_Galaxy's_Most_Wanted_001_(2014)_(Digital)_(Zone-Empire).cbr
https://userscloud.com/0mjhxiqs2581/Guardians_of_the_Galaxy_000.1_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/x5zaf6r3jl1j/Guardians_of_the_Galaxy_001_(2013)_(21_Covers)_(Tarutaru-Novus-HD).cbr
https://userscloud.com/4crnaof2xs2z/Guardians_of_the_Galaxy_001_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/uqv1f5ck7f0m/Guardians_of_the_Galaxy_002_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/8v0giwb7viz1/Guardians_of_the_Galaxy_003_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/sp46pfmmey9i/Guardians_of_the_Galaxy_004_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/502nh7yuldeo/Guardians_of_the_Galaxy_005_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/af6gsgktqbja/Guardians_of_the_Galaxy_006_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/halk009inqjm/Guardians_of_the_Galaxy_007_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/dvbumr6mcrvv/Guardians_of_the_Galaxy_008_(2013)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/2y7y5fgkg9yv/Guardians_of_the_Galaxy_009_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/0v7ba0j0wkfe/Guardians_of_the_Galaxy_010_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/gybuzvd2f6yv/Guardians_of_the_Galaxy_011.NOW_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/6nmcep1qgvr8/Guardians_of_the_Galaxy_012_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/sp0iql83e137/Guardians_of_the_Galaxy_013_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/2xtj97qd1kr6/Guardians_of_the_Galaxy_014_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/n0md9zdsbv1t/Guardians_of_the_Galaxy_015_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/2hgp7ddcxs5b/Guardians_of_the_Galaxy_016_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/2hzavakc0dzu/Guardians_of_the_Galaxy_017_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/704lbeqmyayq/Guardians_of_the_Galaxy_018_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/qi8tldcos67n/Guardians_of_the_Galaxy_019_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/mn0twi9zmtnj/Guardians_of_the_Galaxy_020_(2014)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/irhp953wtyr2/Guardians_of_the_Galaxy_021_(2015)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/xrct2nthoj7d/Guardians_of_the_Galaxy_022_(2015)_(digital)_(Minutemen-PhD).cbr
https://userscloud.com/b48eurvlckyr/Guardians_of_the_Galaxy_023_(2015)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/7oco11vtb4g4/Guardians_of_the_Galaxy_024_(2015)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/mcbz8pj4b0cr/Guardians_Of_Galaxy_025_(2015)_(4_Covers)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/cpm3p6nt1mj9/Guardians_of_the_Galaxy_026_(2015)_(3_covers)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/v8jf25gn8mv1/Guardians_of_the_Galaxy_027_(2015)_(2_covers)_(digital)_(Minutemen-Spaztastic).cbr
https://userscloud.com/tqg94xh14rtp/Guardians_of_the_Galaxy_Annual_001_(2015)_(Digital)_(Zone-Empire).cbr
https://userscloud.com/ws1ery1hlyik/Variants.zip
import os
import sys
import progress
import requests
from bs4 import BeautifulSoup as bf
with open('down_list.txt', 'r') as file:
# link = file.readline()
url_list = [link.strip() for link in file]
cheaders = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:44.0) Gecko/20100101 Firefox/44.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate'}
# <input name="id" type="hidden" value="ws1ery1hlyik"/>
# <input name="rand" type="hidden" value="er3bm5iiaudv2r6t2nze7uuxfftnhsyghwjvduq"/>
for url in url_list:
# res = urllib.request.urlopen(url)
with requests.Session() as s:
s.headers = cheaders
res = s.get(url)
soup = bf(res.text, 'html5lib')
parsed_id = soup.find('input', {'name': 'id'})['value']
parsed_rand = soup.find('input', {'name': 'rand'})['value']
payload = {'op': 'download2',
'id': parsed_id,
'rand': parsed_rand,
'down_script': '1'}
down = s.post(url, data=payload, allow_redirects=False)
to_save_link = down.headers.get('Location')
to_save_name = os.path.basename(to_save_link)
sys.stdout.write('Downloading: {}\n'.format(to_save_name))
to_save_path = os.path.join(os.getcwd(), to_save_name)
save_r = s.get(to_save_link, stream=True)
size_bytes = int(save_r.headers['Content-Length'].strip())
sys.stdout.write('size is {0} bytes or {1:.1f} MB\n'.format(
size_bytes, round(size_bytes / 1024 / 1024, 2)))
if save_r.status_code == 200 and not os.path.isfile(to_save_path):
with open(to_save_path, 'wb') as fd:
for piece in progress.bar(
save_r.iter_content(2048),
expected_size=round(size_bytes / 2048)):
fd.write(piece)
fd.flush()
# -*- coding: utf-8 -*-
"""
clint.textui.progress
~~~~~~~~~~~~~~~~~
This module provides the progressbar functionality.
from https://github.com/kennethreitz/clint
Copyright (c) 2011, Kenneth Reitz <me@kennethreitz.com>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
"""
import sys
import time
STREAM = sys.stdout
BAR_TEMPLATE = '%s[%s%s] %i/%i - %s\r'
MILL_TEMPLATE = '%s %s %i/%i\r'
DOTS_CHAR = '.'
BAR_FILLED_CHAR = '#'
BAR_EMPTY_CHAR = ' '
MILL_CHARS = ['|', '/', '-', '\\']
# How long to wait before recalculating the ETA
ETA_INTERVAL = 2
# How many intervals (excluding the current one)
# to calculate the simple moving average
ETA_SMA_WINDOW = 9
class Bar(object):
def __enter__(self):
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.done()
return False # we're not suppressing exceptions
def __init__(self, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):
self.label = label
self.width = width
self.hide = hide
# Only show bar in terminals by default (better for piping, logging etc.)
if hide is None:
try:
self.hide = not STREAM.isatty()
except AttributeError: # output does not support isatty()
self.hide = True
self.empty_char = empty_char
self.filled_char = filled_char
self.expected_size = expected_size
self.every = every
self.start = time.time()
self.ittimes = []
self.eta = 0
self.etadelta = time.time()
self.etadisp = self.format_time(self.eta)
self.last_progress = 0
self.elapsed = 0
if self.expected_size:
self.show(0)
def show(self, progress, count=None):
if count is not None:
self.expected_size = count
if self.expected_size is None:
raise Exception("expected_size not initialized")
self.last_progress = progress
if (time.time() - self.etadelta) > ETA_INTERVAL:
self.etadelta = time.time()
self.ittimes = \
self.ittimes[-ETA_SMA_WINDOW:] + \
[-(self.start - time.time()) / (progress+1)]
self.eta = \
sum(self.ittimes) / float(len(self.ittimes)) * \
(self.expected_size - progress)
self.etadisp = self.format_time(self.eta)
x = int(self.width * progress / self.expected_size)
if not self.hide:
if ((progress % self.every) == 0 or # True every "every" updates
(progress == self.expected_size)): # And when we're done
STREAM.write(BAR_TEMPLATE % (
self.label, self.filled_char * x,
self.empty_char * (self.width - x), progress,
self.expected_size, self.etadisp))
STREAM.flush()
def done(self):
self.elapsed = time.time() - self.start
elapsed_disp = self.format_time(self.elapsed)
if not self.hide:
# Print completed bar with elapsed time
STREAM.write(BAR_TEMPLATE % (
self.label, self.filled_char * self.width,
self.empty_char * 0, self.last_progress,
self.expected_size, elapsed_disp))
STREAM.write('\n')
STREAM.flush()
@staticmethod
def format_time(seconds):
return time.strftime('%H:%M:%S', time.gmtime(seconds))
def bar(it, label='', width=32, hide=None, empty_char=BAR_EMPTY_CHAR,
filled_char=BAR_FILLED_CHAR, expected_size=None, every=1):
"""Progress iterator. Wrap your iterables with it.
:param it:
:param label:
:param width:
:param hide:
:param empty_char:
:param filled_char:
:param expected_size:
:param every:
"""
count = len(it) if expected_size is None else expected_size
with Bar(label=label, width=width, hide=hide, empty_char=BAR_EMPTY_CHAR,
filled_char=BAR_FILLED_CHAR, expected_size=count, every=every) \
as bar:
for i, item in enumerate(it):
yield item
bar.show(i + 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment