From ae27bc7abfc2469419da81552d622d6b41e7a61c Mon Sep 17 00:00:00 2001 From: Kazuki Przyborowski Date: Mon, 7 Oct 2013 00:16:44 -0500 Subject: [PATCH] Yet another small update. --- MiniScripts/motherless-dl.py | 229 ++++++++++++++++++++++--------------------- 1 file changed, 119 insertions(+), 110 deletions(-) diff --git a/MiniScripts/motherless-dl.py b/MiniScripts/motherless-dl.py index 7608b98..533d749 100755 --- a/MiniScripts/motherless-dl.py +++ b/MiniScripts/motherless-dl.py @@ -13,19 +13,19 @@ 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.4.0 RC 3 - Author: cooldude2k $ + $FileInfo: motherless-dl.py - Last Update: 10/06/2013 Ver. 1.4.5 RC 1 - Author: cooldude2k $ ''' import re, os, sys, httplib, urllib, urllib2, cookielib, StringIO, gzip, time, datetime, argparse, urlparse; -__version_info__ = (1, 4, 0, "RC 3"); +__version_info__ = (1, 4, 5, "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): __version__ = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str(__version_info__[2]); parser = argparse.ArgumentParser(); -parser.add_argument("url", help="motherless url"); +parser.add_argument("url", nargs="*", help="motherless url"); parser.add_argument("--user-agent", nargs="?", default="Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0", help="specify a custom user agent"); parser.add_argument("--referer", nargs="?", default="http://motherless.com/", help="specify a custom referer, use if the video access"); parser.add_argument("--verbose", action='store_true', help="print various debugging information"); @@ -39,78 +39,40 @@ if(getargs.version==True): if(getargs.dump_user_agent==True): print(getargs.user_agent); sys.exit(); -mlessvid = getargs.url; -mlessvid = re.sub(re.escape("http://motherless.com/"), "", mlessvid); -mlessvid = re.sub(re.escape("http://www.motherless.com/"), "", mlessvid); -mlessvid = re.sub(re.escape("motherless.com/"), "", mlessvid); -mlessvid = re.sub(re.escape("www.motherless.com/"), "", mlessvid); -mlessvid = re.sub("^"+re.escape("/"), "", mlessvid); -mlessvid = "http://motherless.com/"+mlessvid; -mregex_text = re.escape("http://motherless.com/")+"([\w\/]+)"; -if(re.findall(mregex_text, mlessvid)): - mlessvid = re.findall(mregex_text, mlessvid); - mlessvid = "/"+mlessvid[0]; +if(len(getargs.url)==0): + parser.print_help(); + sys.exit(); + 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 = 0; per_url_sleep = 0; -mlessvidid = urlparse.urlparse(mlessvid).path.split('/'); -mlessgallist = []; -if((re.match("^random", mlessvidid[1]) and len(mlessvidid)==2) or (re.match("^random", mlessvidid[1]) and len(mlessvidid)==3) and (re.match("^image", mlessvidid[2]) or re.match("^video", mlessvidid[2]))): - geturls_text = geturls_opener.open("http://motherless.com"+mlessvid); - mlessvid = geturls_text.geturl(); + +numurlarg = len(getargs.url); +cururlarg = 0; +while(cururlarg")+"([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()[:]; - out_text = re.sub(re.escape("http://motherless.com"), "", out_text); - out_text = re.sub(re.escape("http://www.motherless.com"), "", out_text); - regex_text = re.escape("")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">"); - post_text = re.findall(regex_text, out_text); - numgal = len(post_text); - curgal = 0; - while(curgal5)): - mlessgallist.append(mlessvid); -numusrgal = len(mlessgallist); -curusrgal = 0; -while(curusrgal1): - geturls_text = geturls_opener.open("http://motherless.com"+mlessvid+"?page="+str(curpage)); + 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()[:]; - out_text = re.sub(re.escape("http://motherless.com"), "", out_text); - out_text = re.sub(re.escape("http://www.motherless.com"), "", out_text); - if(re.match("^V", mlessvidid[1])): - out_text = re.sub(re.escape("class=\"img-container\" target=\"_self\""), "title=\"motherless link\"", out_text); - out_text = re.sub(re.escape("class=\"pop plain\" target=\"_blank\""), "title=\"motherless link\"", out_text); - regex_text = re.escape(""); - if(not re.match("^V", mlessvidid[1])): - regex_text = re.escape("")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">"); + out_text = re.sub(re.escape("http://motherless.com"), "", out_text); + out_text = re.sub(re.escape("http://www.motherless.com"), "", out_text); + regex_text = re.escape("")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">"); post_text = re.findall(regex_text, out_text); - numurls = len(post_text); - cururl = 0; - while(cururl0): - mlesslink = post_text[0]; - mlessext = os.path.splitext(urlparse.urlparse(mlesslink).path)[1]; - mlessext = mlessext.replace(".", ""); - mlessext = mlessext.lower(); - if(mlessext=="mp4" or mlessext=="flv"): - mlesslink = mlesslink+"?start=0"; - print(mlesslink); - if(curlurl<(numlist - 1)): - time.sleep(per_url_sleep); - curlurl = curlurl + 1; - if(curusrgal<(numusrgal - 1)): - time.sleep(per_gal_sleep); - curusrgal = curusrgal + 1; + if(not re.match("^galleries", mlessvidid[1]) or (re.match("^galleries", mlessvidid[1]) and len(mlessvidid)<4) or (re.match("^galleries", mlessvidid[1]) and len(mlessvidid)>5)): + mlessgallist.append(mlessvid); + numusrgal = len(mlessgallist); + curusrgal = 0; + while(curusrgal")+"([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()[:]; + out_text = re.sub(re.escape("http://motherless.com"), "", out_text); + out_text = re.sub(re.escape("http://www.motherless.com"), "", out_text); + if(re.match("^V", mlessvidid[1])): + out_text = re.sub(re.escape("class=\"img-container\" target=\"_self\""), "title=\"motherless link\"", out_text); + out_text = re.sub(re.escape("class=\"pop plain\" target=\"_blank\""), "title=\"motherless link\"", out_text); + regex_text = re.escape(""); + if(not re.match("^V", mlessvidid[1])): + regex_text = re.escape("")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">"); + post_text = re.findall(regex_text, out_text); + numurls = len(post_text); + cururl = 0; + while(cururl0): + mlesslink = post_text[0]; + mlessext = os.path.splitext(urlparse.urlparse(mlesslink).path)[1]; + mlessext = mlessext.replace(".", ""); + mlessext = mlessext.lower(); + if(mlessext=="mp4" or mlessext=="flv"): + mlesslink = mlesslink+"?start=0"; + print(mlesslink); + if(curlurl<(numlist - 1)): + time.sleep(per_url_sleep); + curlurl = curlurl + 1; + if(curusrgal<(numusrgal - 1)): + time.sleep(per_gal_sleep); + curusrgal = curusrgal + 1; + cururlarg = cururlarg + 1; ''' getvidurls_cj = cookielib.CookieJar(); -- 2.11.4.GIT