From b0af65ca25b57f276d20cd997e675a10857f0b6d Mon Sep 17 00:00:00 2001 From: Kazuki Przyborowski Date: Sat, 5 Oct 2013 12:42:46 -0500 Subject: [PATCH] Small update. --- MiniScripts/motherless-dl.py | 80 +++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 23 deletions(-) diff --git a/MiniScripts/motherless-dl.py b/MiniScripts/motherless-dl.py index ace4c91..74fcc6c 100755 --- a/MiniScripts/motherless-dl.py +++ b/MiniScripts/motherless-dl.py @@ -13,12 +13,12 @@ Copyright 2013 Game Maker 2k - http://intdb.sourceforge.net/ Copyright 2013 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski - $FileInfo: motherless-dl.py - Last Update: 05/11/2013 Ver. 1.2.0 RC 2 - Author: cooldude2k $ + $FileInfo: motherless-dl.py - Last Update: 05/11/2013 Ver. 1.3.0 RC 1 - Author: cooldude2k $ ''' import re, os, sys, httplib, urllib, urllib2, cookielib, StringIO, gzip, time, datetime, argparse, urlparse; -__version_info__ = (1, 2, 0, "RC 2"); +__version_info__ = (1, 3, 0, "RC 1"); if(__version_info__[3]!=None): __version__ = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str(__version_info__[2])+" "+str(__version_info__[3]); if(__version_info__[3]==None): @@ -48,25 +48,42 @@ fakeua = getargs.user_agent; geturls_cj = cookielib.CookieJar(); geturls_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(geturls_cj)); geturls_opener.addheaders = [("Referer", getargs.referer), ("User-Agent", fakeua), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-US,en-CA,en-GB,en-UK,en-AU,en-NZ,en-ZA,en;q=0.5"), ("Accept-Charset", "ISO-8859-1,ISO-8859-15,utf-8;q=0.7,*;q=0.7"), ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Connection", "close")]; -per_gal_sleep = 8; -per_url_sleep = 4; +per_gal_sleep = 0; +per_url_sleep = 0; mlessvidid = urlparse.urlparse(mlessvid).path.split('/'); mlessgallist = []; -if(re.match("^galleries", mlessvidid[0]) and len(mlessvidid)==3): - geturls_text = geturls_opener.open("http://motherless.com/"+mlessvid); +if((re.match("^galleries", mlessvidid[0]) and len(mlessvidid)==3) or (re.match("^f", mlessvidid[0]) and re.match("^galleries", mlessvidid[-1]) and len(mlessvidid)==3)): + geturls_text = geturls_opener.open("http://motherless.com/"+mlessvid+"?page=1"); if(geturls_text.info().get("Content-Encoding")=="gzip" or geturls_text.info().get("Content-Encoding")=="deflate"): strbuf = StringIO.StringIO(geturls_text.read()); gzstrbuf = gzip.GzipFile(fileobj=strbuf); out_text = gzstrbuf.read()[:]; if(geturls_text.info().get("Content-Encoding")!="gzip" and geturls_text.info().get("Content-Encoding")!="deflate"): out_text = geturls_text.read()[:]; - regex_text = re.escape(""); - post_text = re.findall(regex_text, out_text); - numgal = len(post_text); - curgal = 0; - while(curgal")+"([0-9]+)"+re.escape(""); + page_text = re.findall(regex_ptext, out_text); + try: + numpages = int(page_text[-1][0]); + except IndexError: + numpages = 1; + curpage = 1; + while(curpage<=numpages): + if(curpage>1): + geturls_text = geturls_opener.open("http://motherless.com/"+mlessvid+"?page="+str(curpage)); + if(geturls_text.info().get("Content-Encoding")=="gzip" or geturls_text.info().get("Content-Encoding")=="deflate"): + strbuf = StringIO.StringIO(geturls_text.read()); + gzstrbuf = gzip.GzipFile(fileobj=strbuf); + out_text = gzstrbuf.read()[:]; + if(geturls_text.info().get("Content-Encoding")!="gzip" and geturls_text.info().get("Content-Encoding")!="deflate"): + out_text = geturls_text.read()[:]; + regex_text = re.escape(""); + post_text = re.findall(regex_text, out_text); + numgal = len(post_text); + curgal = 0; + while(curgal3)): mlessgallist.append(mlessvid); numusrgal = len(mlessgallist); @@ -77,22 +94,39 @@ while(curusrgal"); - post_text = re.findall(regex_text, out_text); - numurls = len(post_text); - cururl = 0; - while(cururl2) or (re.match("^g", mlessvidid[1]) and len(mlessvidid)<3) or (re.match("^g", mlessvidid[1]) and len(mlessvidid)>3)): + regex_ptext = re.escape("class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+re.escape(""); + page_text = re.findall(regex_ptext, out_text); + try: + numpages = int(page_text[-1][0]); + except IndexError: + numpages = 1; + curpage = 1; + while(curpage<=numpages): + if(curpage>1): + geturls_text = geturls_opener.open("http://motherless.com"+mlessvid+"?page="+str(curpage)); + if(geturls_text.info().get("Content-Encoding")=="gzip" or geturls_text.info().get("Content-Encoding")=="deflate"): + strbuf = StringIO.StringIO(geturls_text.read()); + gzstrbuf = gzip.GzipFile(fileobj=strbuf); + out_text = gzstrbuf.read()[:]; + if(geturls_text.info().get("Content-Encoding")!="gzip" and geturls_text.info().get("Content-Encoding")!="deflate"): + out_text = geturls_text.read()[:]; + regex_text = re.escape(""); + post_text = re.findall(regex_text, out_text); + numurls = len(post_text); + cururl = 0; + while(cururl2) and (re.match("^g", mlessvidid[1]) and (len(mlessvidid)<3 or len(mlessvidid)>3)) and (re.match("^f", mlessvidid[1]) and re.match("^videos", mlessvidid[-1]) and (len(mlessvidid)<4 or len(mlessvidid)>4)) and (re.match("^f", mlessvidid[1]) and re.match("^images", mlessvidid[-1]) and (len(mlessvidid)<4 or len(mlessvidid)>4))): mlessurllist.append(mlessvid); numlist = len(mlessurllist); curlurl = 0; -- 2.11.4.GIT