From 8da299e7662b20d89024686de24962520d42fd27 Mon Sep 17 00:00:00 2001 From: Kazuki Suzuki Przyborowski Date: Tue, 8 Oct 2024 15:13:48 -0500 Subject: [PATCH] Small update --- MiniScripts/beeg-dl.py | 17 +- MiniScripts/get_ylp.py | 13 +- MiniScripts/miss-bone-alt.py | 98 +++++--- MiniScripts/miss-bone.py | 99 +++++--- MiniScripts/motherless-dl.py | 587 ++++++++++++++++++++++++++++--------------- MiniScripts/videarn-dl.py | 18 +- PyClock/bin/clock.py | 126 ++++++---- PyXV/xv-alt.py | 15 +- PyXV/xv-dl.py | 64 +++-- PyXV/xv.py | 13 +- 10 files changed, 681 insertions(+), 369 deletions(-) diff --git a/MiniScripts/beeg-dl.py b/MiniScripts/beeg-dl.py index d6cabd9..560b182 100755 --- a/MiniScripts/beeg-dl.py +++ b/MiniScripts/beeg-dl.py @@ -16,25 +16,26 @@ $FileInfo: beeg-dl.py - Last Update: 10/07/2013 Ver. 1.0.5 RC 6 - Author: cooldude2k $ ''' -import re +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse parser = argparse.ArgumentParser() parser.add_argument("url", help="beeg url") getargs = parser.parse_args() mlessvid = getargs.url -mregex_text = re.escape("http://beeg.com/")+"([a-zA-Z0-9\/]+)" -if(re.findall(mregex_text, mlessvid)): +mregex_text = re.escape("http://beeg.com/") + "([a-zA-Z0-9\\/]+)" +if (re.findall(mregex_text, mlessvid)): mlessvid = re.findall(mregex_text, mlessvid) mlessvid = mlessvid[0] fakeua = "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"" diff --git a/MiniScripts/get_ylp.py b/MiniScripts/get_ylp.py index 0f32a76..21f13b5 100755 --- a/MiniScripts/get_ylp.py +++ b/MiniScripts/get_ylp.py @@ -16,17 +16,18 @@ $FileInfo: get_ylp.py - Last Update: 10/07/2013 Ver. 1.0.5 RC 6 - Author: cooldude2k $ ''' -import re +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse fakeua = "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"" diff --git a/MiniScripts/miss-bone-alt.py b/MiniScripts/miss-bone-alt.py index 0c460c6..944aec2 100755 --- a/MiniScripts/miss-bone-alt.py +++ b/MiniScripts/miss-bone-alt.py @@ -16,67 +16,103 @@ Copyright 2014 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski $FileInfo: miss-bone-alt.py - Last Update: 6/12/2014 Ver. 1.0.0 RC 1 - Author: cooldude2k $ ''' -import re +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse fakeua = "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0" geturls_cj = cookielib.CookieJar() geturls_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(geturls_cj)) -geturls_opener.addheaders = [("Referer", "http://www.cute-factor.com/general-news/835-more-than-400-miss-bone-emoticons.html"), ("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")] +geturls_opener.addheaders = [ + ("Referer", + "http://www.cute-factor.com/general-news/835-more-than-400-miss-bone-emoticons.html"), + ("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")] sfcountsub = 0 sfcountfull = 0 i = 1 il = 11 -while(i < il): - print(str(i)+" Reading URL: http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page="+str(i)) +while (i < il): + print( + str(i) + + " Reading URL: http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page=" + + str(i)) geturls_text = geturls_opener.open( - "http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page="+str(i)) - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + "http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page=" + + str(i)) + 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"): + 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("Miss Bone Emoticons ") + \
-        "([0-9]+)"+re.escape("") + "([0-9]+)" + re.escape("' src=\"") + "(.*?)" + re.escape("\" border=0>") post_text = re.findall(regex_text, out_text) isub = 0 ilsub = len(post_text) - print(str(i)+" Found "+str(ilsub)+" GIF Images.") - while(isub < ilsub): + print(str(i) + " Found " + str(ilsub) + " GIF Images.") + while (isub < ilsub): getsub2xurls_cj = geturls_cj getsub2xurls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(getsub2xurls_cj)) - getsub2xurls_opener.addheaders = [("Referer", "http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page="+str(i)), ("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")] - print(str(i)+","+str(isub+1)+" Start Downloading Image File: " + - str(isub+1)+" of "+str(ilsub)) - print(str(i)+","+str(isub+1)+" Downloading Image: "+post_text[isub][1]) + getsub2xurls_opener.addheaders = [ + ("Referer", + "http://www.cute-factor.com/imlister.php?cid=missbone&type=e&pp=49&page=" + + str(i)), + ("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")] + print(str(i) + "," + str(isub + 1) + " Start Downloading Image File: " + + str(isub + 1) + " of " + str(ilsub)) + print(str(i) + "," + str(isub + 1) + + " Downloading Image: " + post_text[isub][1]) getsub2xurls_text = getsub2xurls_opener.open(post_text[isub][1]) gif_file_name = os.path.basename( urlparse.urlparse(post_text[isub][1]).path) - print(str(i)+","+str(isub+1) + - " Finished Downloading Image: "+post_text[isub][1]) - print(str(i)+","+str(isub+1)+" Saving File: ./"+gif_file_name) - gifsf = open("./"+gif_file_name, "wb") + print(str(i) + "," + str(isub + 1) + + " Finished Downloading Image: " + post_text[isub][1]) + print(str(i) + "," + str(isub + 1) + + " Saving File: ./" + gif_file_name) + gifsf = open("./" + gif_file_name, "wb") gifsf.write(getsub2xurls_text.read()) gifsf.close() - isub = isub+1 - sfcountsub = sfcountsub+1 - print(str(i)+" Downloaded "+str(sfcountsub)+" GIF Images") - sfcountfull = sfcountfull+sfcountsub + isub = isub + 1 + sfcountsub = sfcountsub + 1 + print(str(i) + " Downloaded " + str(sfcountsub) + " GIF Images") + sfcountfull = sfcountfull + sfcountsub sfcountsub = 0 - i = i+1 -print("Downloaded "+str(sfcountfull)+" GIF Images") + i = i + 1 +print("Downloaded " + str(sfcountfull) + " GIF Images") sfcountfull = 0 diff --git a/MiniScripts/miss-bone.py b/MiniScripts/miss-bone.py index 730c44f..63211fb 100755 --- a/MiniScripts/miss-bone.py +++ b/MiniScripts/miss-bone.py @@ -16,68 +16,103 @@ Copyright 2014 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski $FileInfo: miss-bone.py - Last Update: 6/12/2014 Ver. 1.0.0 RC 2 - Author: cooldude2k $ ''' -import re +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse fakeua = "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0" geturls_cj = cookielib.CookieJar() geturls_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(geturls_cj)) -geturls_opener.addheaders = [("Referer", "http://www.emoticonplus.com/miss-bone/"), ("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")] +geturls_opener.addheaders = [ + ("Referer", + "http://www.emoticonplus.com/miss-bone/"), + ("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")] sfcountsub = 0 sfcountfull = 0 i = 1 il = 15 -while(i < il): - print(str(i)+" Reading URL: http://www.emoticonplus.com/miss-bone/page/"+str(i)) +while (i < il): + print( + str(i) + + " Reading URL: http://www.emoticonplus.com/miss-bone/page/" + + str(i)) geturls_text = geturls_opener.open( - "http://www.emoticonplus.com/miss-bone/page/"+str(i)) - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + "http://www.emoticonplus.com/miss-bone/page/" + str(i)) + 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"): + 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) isub = 0 ilsub = len(post_text) - print(str(i)+" Found "+str(ilsub)+" GIF Images.") - while(isub < ilsub): + print(str(i) + " Found " + str(ilsub) + " GIF Images.") + while (isub < ilsub): getsub2xurls_cj = geturls_cj getsub2xurls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(getsub2xurls_cj)) - getsub2xurls_opener.addheaders = [("Referer", "http://www.emoticonplus.com/miss-bone/page/"+str(i)), ("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")] - print(str(i)+","+str(isub+1)+" Start Downloading Image File: " + - str(isub+1)+" of "+str(ilsub)) - print(str(i)+","+str(isub+1)+" Downloading Image: "+post_text[isub][0]) + getsub2xurls_opener.addheaders = [ + ("Referer", + "http://www.emoticonplus.com/miss-bone/page/" + + str(i)), + ("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")] + print(str(i) + "," + str(isub + 1) + " Start Downloading Image File: " + + str(isub + 1) + " of " + str(ilsub)) + print(str(i) + "," + str(isub + 1) + + " Downloading Image: " + post_text[isub][0]) getsub2xurls_text = getsub2xurls_opener.open(post_text[isub][0]) gif_file_name = os.path.basename( urlparse.urlparse(post_text[isub][0]).path) - print(str(i)+","+str(isub+1) + - " Finished Downloading Image: "+post_text[isub][0]) - print(str(i)+","+str(isub+1)+" Saving File: ./"+gif_file_name) - gifsf = open("./"+gif_file_name, "wb") + print(str(i) + "," + str(isub + 1) + + " Finished Downloading Image: " + post_text[isub][0]) + print(str(i) + "," + str(isub + 1) + + " Saving File: ./" + gif_file_name) + gifsf = open("./" + gif_file_name, "wb") gifsf.write(getsub2xurls_text.read()) gifsf.close() - isub = isub+1 - sfcountsub = sfcountsub+1 - print(str(i)+" Downloaded "+str(sfcountsub)+" GIF Images") - sfcountfull = sfcountfull+sfcountsub + isub = isub + 1 + sfcountsub = sfcountsub + 1 + print(str(i) + " Downloaded " + str(sfcountsub) + " GIF Images") + sfcountfull = sfcountfull + sfcountsub sfcountsub = 0 - i = i+1 -print("Downloaded "+str(sfcountfull)+" GIF Images") + i = i + 1 +print("Downloaded " + str(sfcountfull) + " GIF Images") sfcountfull = 0 diff --git a/MiniScripts/motherless-dl.py b/MiniScripts/motherless-dl.py index 0143512..be72639 100755 --- a/MiniScripts/motherless-dl.py +++ b/MiniScripts/motherless-dl.py @@ -16,42 +16,52 @@ $FileInfo: motherless-dl.py - Last Update: 11/10/2013 Ver. 1.6.7 RC 1 - Author: cooldude2k $ ''' -from __future__ import division, absolute_import, print_function -import re +from __future__ import absolute_import, division, print_function + +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse -if(__name__ == "__main__"): + +if (__name__ == "__main__"): sys.tracebacklimit = 0 __version_info__ = (1, 6, 5, "RC 3") __version_date__ = "2013.10.23" -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]) +if (__version_info__[3] is not None): + __version__ = str(__version_info__[0]) + "." + str(__version_info__[1]) + "." + str( + __version_info__[2]) + " " + str(__version_info__[3]) +if (__version_info__[3] is None): + __version__ = str(__version_info__[ + 0]) + "." + str(__version_info__[1]) + "." + str(__version_info__[2]) parser = argparse.ArgumentParser( - description="get urls of images/videos from motherless.com", conflict_handler="resolve", add_help=True) + description="get urls of images/videos from motherless.com", + conflict_handler="resolve", + add_help=True) parser.add_argument("url", nargs='*', help='motherless url') parser.add_argument('-v', '--version', action='version', version=__version__) parser.add_argument("--pages-start", nargs="*", help="start at page number") parser.add_argument("--pages-end", nargs="*", help="end at page number") -parser.add_argument("--update", action='store_true', - help="update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)") +parser.add_argument( + "--update", + action='store_true', + help="update this program to latest version. Make sure that you have sufficient permissions (run with sudo if needed)") parser.add_argument("--dump-user-agent", action='store_true', help="display the current browser identification") -parser.add_argument("--user-agent", nargs="?", - default="Mozilla/5.0 (Windows NT 7.0; rv:25.0) Gecko/20100101 Firefox/25.0", help="specify a custom user agent") +parser.add_argument( + "--user-agent", + nargs="?", + default="Mozilla/5.0 (Windows NT 7.0; rv:25.0) Gecko/20100101 Firefox/25.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("--proxy", nargs="?", default=None, @@ -82,8 +92,10 @@ parser.add_argument("--get-bbcode", action='store_true', help="simulate, quiet but print bbcode") parser.add_argument("--get-html", action='store_true', help="simulate, quiet but print html code") -parser.add_argument("--get-dimensions", action='store_true', - help="simulate, quiet but print dimensions (width x height)") +parser.add_argument( + "--get-dimensions", + action='store_true', + help="simulate, quiet but print dimensions (width x height)") parser.add_argument("--get-width", action='store_true', help="simulate, quiet but print width") parser.add_argument("--get-height", action='store_true', @@ -95,55 +107,70 @@ parser.add_argument("--get-favorites", action='store_true', parser.add_argument("--verbose", action='store_true', help="print various debugging information") getargs = parser.parse_args() -if(getargs.update == True): +if (getargs.update): from distutils.version import LooseVersion as VerCheck fakeua = getargs.user_agent proxycfg = None - if(getargs.proxy != None): + if (getargs.proxy is not None): proxycfg = urllib2.ProxyHandler({"http": getargs.proxy}) geturls_cj = cookielib.CookieJar() - if(proxycfg == None): + if (proxycfg is None): geturls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(geturls_cj)) - if(proxycfg != None): + if (proxycfg is not None): geturls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(geturls_cj), proxycfg) - geturls_opener.addheaders = [("Referer", "https://github.com/GameMaker2k/Python-Scripts/"), ("User-Agent", fakeua), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-US,en;q=0.8,en-CA,en-GB;q=0.6"), - ("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")] + geturls_opener.addheaders = [ + ("Referer", + "https://github.com/GameMaker2k/Python-Scripts/"), + ("User-Agent", + fakeua), + ("Accept-Encoding", + "gzip, deflate"), + ("Accept-Language", + "en-US,en;q=0.8,en-CA,en-GB;q=0.6"), + ("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")] urllib2.install_opener(geturls_opener) geturls_text = geturls_opener.open( "https://raw.github.com/GameMaker2k/Python-Scripts/master/MiniScripts/motherless-dl.py") - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + 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) pyfile_text = gzstrbuf.read()[:] - if(geturls_text.info().get("Content-Encoding") != "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): + if (geturls_text.info().get("Content-Encoding") != + "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): pyfile_text = geturls_text.read()[:] regex_finddate_text = re.escape( - "__version_date__ = \"")+"([0-9\.]+)"+re.escape("\"") + "__version_date__ = \"") + "([0-9\\.]+)" + re.escape("\"") finddate_text = re.findall(regex_finddate_text, pyfile_text) - regex_findver_text = re.escape("__version_info__ = (")+"([0-9]+)"+re.escape( - ", ")+"([0-9]+)"+re.escape(", ")+"([0-9]+)"+re.escape(", \"")+"([A-Z0-9 ]+)"+re.escape("\");") + regex_findver_text = re.escape("__version_info__ = (") + "([0-9]+)" + re.escape( + ", ") + "([0-9]+)" + re.escape(", ") + "([0-9]+)" + re.escape(", \"") + "([A-Z0-9 ]+)" + re.escape("\");") findver_text = re.findall(regex_findver_text, pyfile_text) - ProVerStr = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str( - __version_info__[2])+__version_info__[3].replace(" ", "").lower() + ProVerStr = str(__version_info__[0]) + "." + str(__version_info__[1]) + "." + str( + __version_info__[2]) + __version_info__[3].replace(" ", "").lower() ProVerCheck = VerCheck(ProVerStr) ProDateCheck = VerCheck(__version_date__) - NewVerStr = findver_text[0][0]+"."+findver_text[0][1]+"." + \ - findver_text[0][2]+findver_text[0][3].replace(" ", "").lower() + NewVerStr = findver_text[0][0] + "." + findver_text[0][1] + "." + \ + findver_text[0][2] + findver_text[0][3].replace(" ", "").lower() NewVerCheck = VerCheck(NewVerStr) NewDateCheck = VerCheck(finddate_text[0]) - if(ProVerStr < NewVerCheck and ProDateCheck <= NewDateCheck): + if (ProVerStr < NewVerCheck and ProDateCheck <= NewDateCheck): fileopen = open(__file__, "w+") fileopen.write(pyfile_text) fileopen.close() print() sys.exit() -if(getargs.dump_user_agent == True): +if (getargs.dump_user_agent): print(getargs.user_agent) sys.exit() -if(len(getargs.url) == 0): +if (len(getargs.url) == 0): parser.print_help() sys.exit() @@ -151,43 +178,62 @@ if(len(getargs.url) == 0): def motherless_dl(mtlessgetargs=vars(getargs)): fakeua = mtlessgetargs["user_agent"] proxycfg = None - if(mtlessgetargs["proxy"] != None): + if (mtlessgetargs["proxy"] is not None): proxycfg = urllib2.ProxyHandler({"http": mtlessgetargs["proxy"]}) geturls_cj = cookielib.CookieJar() - if(proxycfg == None): + if (proxycfg is None): geturls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(geturls_cj)) - if(proxycfg != None): + if (proxycfg is not None): geturls_opener = urllib2.build_opener( urllib2.HTTPCookieProcessor(geturls_cj), proxycfg) - geturls_opener.addheaders = [("Referer", mtlessgetargs["referer"]), ("User-Agent", fakeua), ("Accept-Encoding", "gzip, deflate"), ("Accept-Language", "en-US,en;q=0.8,en-CA,en-GB;q=0.6"), - ("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")] + geturls_opener.addheaders = [ + ("Referer", + mtlessgetargs["referer"]), + ("User-Agent", + fakeua), + ("Accept-Encoding", + "gzip, deflate"), + ("Accept-Language", + "en-US,en;q=0.8,en-CA,en-GB;q=0.6"), + ("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")] urllib2.install_opener(geturls_opener) per_gal_sleep = 0 per_url_sleep = 0 numurlarg = len(mtlessgetargs["url"]) cururlarg = 0 - while(cururlarg < numurlarg): + while (cururlarg < numurlarg): mlessvid = mtlessgetargs["url"][cururlarg] - if(re.match("^s([0-9]+)"+re.escape(".motherlessmedia.com"), urlparse.urlparse(mlessvid).hostname)): + if (re.match("^s([0-9]+)" + re.escape(".motherlessmedia.com"), + urlparse.urlparse(mlessvid).hostname)): geturls_text = geturls_opener.open( - "http://motherless.com/mogile_api.php?path="+urllib.quote_plus(mlessvid)+"&redirect=1") + "http://motherless.com/mogile_api.php?path=" + + urllib.quote_plus(mlessvid) + + "&redirect=1") mlessvid = geturls_text.geturl() - mregex_text = re.escape("http://motherless.com/")+"([\w\/\?\&\=]+)" - if(re.findall(mregex_text, mlessvid)): + mregex_text = re.escape( + "http://motherless.com/") + "([\\w\\/\\?\\&\\=]+)" + if (re.findall(mregex_text, mlessvid)): mlessvid = re.findall(mregex_text, mlessvid) - mlessvid = "http://motherless.com/"+mlessvid[0] - if(mtlessgetargs["verbose"] == True): + mlessvid = "http://motherless.com/" + mlessvid[0] + if (mtlessgetargs["verbose"]): print(mlessvid) - if(re.match("^"+re.escape("thumbs.motherlessmedia.com"), urlparse.urlparse(mlessvid).hostname)): + if (re.match("^" + re.escape("thumbs.motherlessmedia.com"), + urlparse.urlparse(mlessvid).hostname)): mlessvid = re.sub(re.escape("-zoom"), "", mlessvid) mlessvid = re.sub(re.escape("-strip"), "", mlessvid) mlessvidtmp = urlparse.urlparse(mlessvid).path.split("/") - mlessvid = "http://motherless.com/"+mlessvidtmp[2] - mregex_text = re.escape("http://motherless.com/")+"([\w\/\?\&\=]+)" - if(re.findall(mregex_text, mlessvid)): + mlessvid = "http://motherless.com/" + mlessvidtmp[2] + mregex_text = re.escape( + "http://motherless.com/") + "([\\w\\/\\?\\&\\=]+)" + if (re.findall(mregex_text, mlessvid)): mlessvid = re.findall(mregex_text, mlessvid) - mlessvid = "http://motherless.com/"+mlessvid[0] + mlessvid = "http://motherless.com/" + mlessvid[0] mlessvid = re.sub(re.escape("http://motherless.com/"), "", mlessvid) mlessvid = re.sub( re.escape("http://www.motherless.com/"), "", mlessvid) @@ -196,32 +242,44 @@ def motherless_dl(mtlessgetargs=vars(getargs)): re.escape("https://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.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] + mlessvid = "/" + mlessvid[0] mlessvidqstr = urlparse.parse_qs(urlparse.urlparse(mlessvid).query) 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]))): + 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) + "http://motherless.com" + mlessvid) mlessvid = geturls_text.geturl() - if(re.findall(mregex_text, mlessvid)): + if (re.findall(mregex_text, mlessvid)): mlessvid = re.findall(mregex_text, mlessvid) mlessvid = mlessvid[0] - if(mtlessgetargs["verbose"] == True): + if (mtlessgetargs["verbose"]): print(mlessvid) - if((re.match("^galleries", mlessvidid[1]) and len(mlessvidid) == 4) or (re.match("^f", mlessvidid[1]) and re.match("^galleries", mlessvidid[2]) and len(mlessvidid) == 4) or (re.match("^term", mlessvidid[1]) and re.match("^galleries", mlessvidid[2]) and len(mlessvidid) == 4)): + if ((re.match("^galleries", + mlessvidid[1]) and len(mlessvidid) == 4) or (re.match("^f", + mlessvidid[1]) and re.match("^galleries", + mlessvidid[2]) and len(mlessvidid) == 4) or (re.match("^term", + mlessvidid[1]) and re.match("^galleries", + mlessvidid[2]) and len(mlessvidid) == 4)): 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"): + "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"): + 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( @@ -231,30 +289,34 @@ def motherless_dl(mtlessgetargs=vars(getargs)): out_text = re.sub( re.escape("https://www.motherless.com"), "", out_text) regex_ptext = re.escape( - "class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+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 - if(not mtlessgetargs["pages_start"] == None and mtlessgetargs["pages_start"][0].isdigit()): - if(int(mtlessgetargs["pages_start"][0]) <= numpages): + if (not mtlessgetargs["pages_start"] + is None and mtlessgetargs["pages_start"][0].isdigit()): + if (int(mtlessgetargs["pages_start"][0]) <= numpages): curpage = int(mtlessgetargs["pages_start"][0]) - if(not mtlessgetargs["pages_end"] == None and mtlessgetargs["pages_end"][0].isdigit()): - if(int(mtlessgetargs["pages_end"][0]) >= curpage): + if (not mtlessgetargs["pages_end"] + is None and mtlessgetargs["pages_end"][0].isdigit()): + if (int(mtlessgetargs["pages_end"][0]) >= curpage): numpages = int(mtlessgetargs["pages_end"][0]) - if(int(mtlessgetargs["pages_end"][0]) <= numpages): + if (int(mtlessgetargs["pages_end"][0]) <= numpages): numpages = int(mtlessgetargs["pages_end"][0]) - while(curpage <= numpages): - if(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"): + "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"): + 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) @@ -265,46 +327,119 @@ def motherless_dl(mtlessgetargs=vars(getargs)): out_text = re.sub( re.escape("http://www.motherless.com"), "", out_text) regex_text = re.escape( - "")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">") + "") + "([\\w\\/]+)" + re.escape("\" class=\"img-container\" target=\"_self\">") post_text = re.findall(regex_text, out_text) numgal = len(post_text) curgal = 0 - while(curgal < numgal): + while (curgal < numgal): mlessgallist.append(post_text[curgal]) - if(mtlessgetargs["verbose"] == True): + if (mtlessgetargs["verbose"]): print(post_text[curgal]) curgal = curgal + 1 curpage = curpage + 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)): + 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 < numusrgal): + while (curusrgal < numusrgal): mlessvid = mlessgallist[curusrgal] - if(not re.match("^\/", mlessvid)): - mlessvid = "/"+mlessvid + if (not re.match("^\\/", mlessvid)): + mlessvid = "/" + mlessvid mlessvidqstr = urlparse.parse_qs(urlparse.urlparse(mlessvid).query) mlessvidid = urlparse.urlparse(mlessvid).path.split("/") mlessurllist = [] - if((re.match("^G", mlessvidid[1]) and len(mlessvidid) == 2) or (re.match("^H", mlessvidid[1]) and len(mlessvidid) == 2) or (re.match("^V", mlessvidid[1]) and len(mlessvidid) == 2) or (re.match("^live", mlessvidid[1]) and len(mlessvidid) == 2) or (re.match("^g", mlessvidid[1]) and len(mlessvidid) == 3) or (re.match("^u", mlessvidid[1]) and len(mlessvidid) == 3) or (re.match("^term", mlessvidid[1]) and (re.match("^videos", mlessvidid[2]) or re.match("^images", mlessvidid[2])) and len(mlessvidid) == 4) or (re.match("^f", mlessvidid[1]) and len(mlessvidid) == 4 and (re.match("^videos", mlessvidid[3]) or re.match("^images", mlessvidid[3]))) or (re.match("^live", mlessvidid[1]) and len(mlessvidid) == 3 and (re.match("^images", mlessvidid[2]) or re.match("^videos", mlessvidid[2]))) or (re.match("^images", mlessvidid[1]) and len(mlessvidid) == 3 and (re.match("^favorited", mlessvidid[2]) or re.match("^viewed", mlessvidid[2]) or re.match("^commented", mlessvidid[2]) or re.match("^popular", mlessvidid[2]))) or (re.match("^videos", mlessvidid[1]) and len(mlessvidid) == 3 and (re.match("^favorited", mlessvidid[2]) or re.match("^viewed", mlessvidid[2]) or re.match("^commented", mlessvidid[2]) or re.match("^popular", mlessvidid[2])))): + if ( + ( + re.match( + "^G", + mlessvidid[1]) and len(mlessvidid) == 2) or ( + re.match( + "^H", + mlessvidid[1]) and len(mlessvidid) == 2) or ( + re.match( + "^V", + mlessvidid[1]) and len(mlessvidid) == 2) or ( + re.match( + "^live", + mlessvidid[1]) and len(mlessvidid) == 2) or ( + re.match( + "^g", + mlessvidid[1]) and len(mlessvidid) == 3) or ( + re.match( + "^u", + mlessvidid[1]) and len(mlessvidid) == 3) or ( + re.match( + "^term", + mlessvidid[1]) and ( + re.match( + "^videos", + mlessvidid[2]) or re.match( + "^images", + mlessvidid[2])) and len(mlessvidid) == 4) or ( + re.match( + "^f", + mlessvidid[1]) and len(mlessvidid) == 4 and ( + re.match( + "^videos", + mlessvidid[3]) or re.match( + "^images", + mlessvidid[3]))) or ( + re.match( + "^live", + mlessvidid[1]) and len(mlessvidid) == 3 and ( + re.match( + "^images", + mlessvidid[2]) or re.match( + "^videos", + mlessvidid[2]))) or ( + re.match( + "^images", + mlessvidid[1]) and len(mlessvidid) == 3 and ( + re.match( + "^favorited", + mlessvidid[2]) or re.match( + "^viewed", + mlessvidid[2]) or re.match( + "^commented", + mlessvidid[2]) or re.match( + "^popular", + mlessvidid[2]))) or ( + re.match( + "^videos", + mlessvidid[1]) and len(mlessvidid) == 3 and ( + re.match( + "^favorited", + mlessvidid[2]) or re.match( + "^viewed", + mlessvidid[2]) or re.match( + "^commented", + mlessvidid[2]) or re.match( + "^popular", + mlessvidid[2])))): addtvar = False tvaradd = "" - if(re.match("^u", mlessvidid[1]) and len(mlessvidid) == 3): + if (re.match("^u", mlessvidid[1]) and len(mlessvidid) == 3): try: - if(mlessvidqstr["t"][0] == "i" or mlessvidqstr["t"][0] == "v"): - tvaradd = "&t="+mlessvidqstr["t"][0] + if (mlessvidqstr["t"][0] == + "i" or mlessvidqstr["t"][0] == "v"): + tvaradd = "&t=" + mlessvidqstr["t"][0] addtvar = True except KeyError: addtvar = False except IndexError: addtvar = False geturls_text = geturls_opener.open( - "http://motherless.com"+mlessvid+"?page=1"+tvaradd) - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + "http://motherless.com" + mlessvid + "?page=1" + tvaradd) + 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"): + 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) @@ -315,30 +450,34 @@ def motherless_dl(mtlessgetargs=vars(getargs)): out_text = re.sub( re.escape("http://www.motherless.com"), "", out_text) regex_ptext = re.escape( - "class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+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 - if(not mtlessgetargs["pages_start"] == None and mtlessgetargs["pages_start"][0].isdigit()): - if(int(mtlessgetargs["pages_start"][0]) <= numpages): + if (not mtlessgetargs["pages_start"] + is None and mtlessgetargs["pages_start"][0].isdigit()): + if (int(mtlessgetargs["pages_start"][0]) <= numpages): curpage = int(mtlessgetargs["pages_start"][0]) - if(not mtlessgetargs["pages_end"] == None and mtlessgetargs["pages_end"][0].isdigit()): - if(int(mtlessgetargs["pages_end"][0]) >= curpage): + if (not mtlessgetargs["pages_end"] + is None and mtlessgetargs["pages_end"][0].isdigit()): + if (int(mtlessgetargs["pages_end"][0]) >= curpage): numpages = int(mtlessgetargs["pages_end"][0]) - if(int(mtlessgetargs["pages_end"][0]) <= numpages): + if (int(mtlessgetargs["pages_end"][0]) <= numpages): numpages = int(mtlessgetargs["pages_end"][0]) - while(curpage <= numpages): - if(curpage > 1): + while (curpage <= numpages): + if (curpage > 1): geturls_text = geturls_opener.open( - "http://motherless.com"+mlessvid+"?page="+str(curpage)+tvaradd) - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + "http://motherless.com" + mlessvid + "?page=" + str(curpage) + tvaradd) + 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"): + 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) @@ -348,43 +487,61 @@ def motherless_dl(mtlessgetargs=vars(getargs)): 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) + 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])): + "") + if (not re.match("^V", mlessvidid[1])): regex_text = re.escape( - "")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">") + "") + "([\\w\\/]+)" + re.escape("\" class=\"img-container\" target=\"_self\">") post_text = re.findall(regex_text, out_text) numurls = len(post_text) cururl = 0 - while(cururl < numurls): + while (cururl < numurls): mlessurllist.append(post_text[cururl]) - if(mtlessgetargs["verbose"] == True): + if (mtlessgetargs["verbose"]): print(post_text[cururl]) cururl = cururl + 1 curpage = curpage + 1 - if((re.match("^G", mlessvidid[1]) and len(mlessvidid) == 3 and re.match("([0-9A-F]+)", mlessvidid[2])) or (re.match("^g", mlessvidid[1]) and len(mlessvidid) == 4) or (len(mlessvidid) == 2 and re.match("([0-9A-F]+)", mlessvidid[1]))): + if ( + ( + re.match( + "^G", + mlessvidid[1]) and len(mlessvidid) == 3 and re.match( + "([0-9A-F]+)", + mlessvidid[2])) or ( + re.match( + "^g", + mlessvidid[1]) and len(mlessvidid) == 4) or ( + len(mlessvidid) == 2 and re.match( + "([0-9A-F]+)", + mlessvidid[1]))): mlessurllist.append(mlessvid) numlist = len(mlessurllist) curlurl = 0 mlessoutlist = [] - while(curlurl < numlist): + while (curlurl < numlist): skiplnk = False try: geturls_text = geturls_opener.open( - "http://motherless.com"+mlessurllist[curlurl]) + "http://motherless.com" + mlessurllist[curlurl]) except urllib2.HTTPError: skiplnk = True - if(skiplnk == False): - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + if (skiplnk == False): + 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) subout_text = gzstrbuf.read()[:] - if(geturls_text.info().get("Content-Encoding") != "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): + if (geturls_text.info().get("Content-Encoding") != + "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): subout_text = geturls_text.read()[:] subout_text = re.sub( re.escape("http://motherless.com"), "", subout_text) @@ -395,60 +552,60 @@ def motherless_dl(mtlessgetargs=vars(getargs)): subout_text = re.sub( re.escape("http://www.motherless.com"), "", subout_text) regex_title = re.escape( - "")+"(.*)"+re.escape("") + "") + "(.*)" + re.escape("") title_text = re.findall(regex_title, subout_text) mlesstitle = re.sub( re.escape(" - MOTHERLESS.COM"), "", title_text[0]) regex_thumb = re.escape( - "src="")+"(.*)"+re.escape(""") + "src="") + "(.*)" + re.escape(""") thumb_text = re.findall(regex_thumb, subout_text) mlessthumb = thumb_text[0] regex_text = re.escape( - "__fileurl = '")+"(.*)"+re.escape("';") + "__fileurl = '") + "(.*)" + re.escape("';") post_text = re.findall(regex_text, subout_text) regex_img = re.escape( - "") + "") img_text = re.findall(regex_img, subout_text) mlessimg = img_text[0] regex_mediatype = re.escape( - "__mediatype = '")+"(.*)"+re.escape("',") + "__mediatype = '") + "(.*)" + re.escape("',") mediatype_text = re.findall(regex_mediatype, subout_text) - regex_altimg = re.escape( - "") + regex_altimg = re.escape("") altimg_text = re.findall(regex_altimg, subout_text) mlessaltimg = altimg_text[0][1] - regex_usrname = re.escape("Uploads") usrname_text = re.findall(regex_usrname, subout_text) mlessusrname = usrname_text[0] - mlessid = re.sub("^"+re.escape("/"), "", + mlessid = re.sub("^" + re.escape("/"), "", mlessurllist[curlurl]) - mlesspurl = "http://motherless.com"+mlessurllist[curlurl] + mlesspurl = "http://motherless.com" + mlessurllist[curlurl] regex_numviews = re.escape( - "Views")+"\n+\t+([^\t]+)\t+"+re.escape("") + "Views") + "\n+\t+([^\t]+)\t+" + re.escape("") numviews_text = re.findall(regex_numviews, subout_text) mlessnumviews = numviews_text[0] mlessnumviews = re.sub(re.escape(","), "", mlessnumviews) regex_numfavs = re.escape( - "Favorited")+"\n+\t+([^\t]+)\t+"+re.escape("") + "Favorited") + "\n+\t+([^\t]+)\t+" + re.escape("") numfavs_text = re.findall(regex_numfavs, subout_text) mlessnumfavs = numfavs_text[0] mlessnumfavs = re.sub(re.escape(","), "", mlessnumfavs) - ''' some good regex "!-%'-?A-~ " "!-%'-?A-~ \<\>\"\'\@\#" ''' - regex_postdata = re.escape("
")+"\n\t+"+re.escape("

")+"\n\t+"+re.escape("")+"\n\t+([^\t]+)\t+"+re.escape( - "")+"\n\t+"+re.escape("

")+"\n\t+"+re.escape("
")+"\n\t+([^\t]+)\t+"+re.escape("
")+"\n\t+"+re.escape("
")+"\n\t+([^\t]+)\t+"+re.escape("
") + ''' some good regex "!-%'-?A-~ " "!-%'-?A-~ \\<\\>\"\'\\@\\#" ''' + regex_postdata = re.escape("
") + "\n\t+" + re.escape("

") + "\n\t+" + re.escape("") + "\n\t+([^\t]+)\t+" + re.escape( + "") + "\n\t+" + re.escape("

") + "\n\t+" + re.escape("
") + "\n\t+([^\t]+)\t+" + re.escape("
") + "\n\t+" + re.escape("
") + "\n\t+([^\t]+)\t+" + re.escape("
") postdata_text = re.findall(regex_postdata, subout_text) numpost = len(postdata_text) regex_servsecs = re.escape( - "Served by web")+"([0-9]+)"+re.escape(" in ")+"([0-9\.]+)"+re.escape(" seconds") + "Served by web") + "([0-9]+)" + re.escape(" in ") + "([0-9\\.]+)" + re.escape(" seconds") servsecs_text = re.findall(regex_servsecs, subout_text) - servname = "web"+servsecs_text[0][0] + servname = "web" + servsecs_text[0][0] servsecs = float(servsecs_text[0][1]) curpost = 0 mlesspostlist = [] ''' From Amber @ http://stackoverflow.com/a/9662362 ''' TAG_RE = re.compile(r'<[^>]+>') - while(numpost > 0 and curpost < numpost): + while (numpost > 0 and curpost < numpost): newpostext = re.sub( re.escape("
"), "\n", postdata_text[curpost][3]) newpostext = re.sub( @@ -457,62 +614,87 @@ def motherless_dl(mtlessgetargs=vars(getargs)): re.escape("
"), "\n", newpostext) newpostext = TAG_RE.sub('', newpostext) newpostext = re.sub( - re.escape("/")+"([\w\/]+)", r"http://motherless.com/\1", newpostext) - mlesspostlist.append({"username": postdata_text[curpost][0], "avatar": "http://avatars.motherlessmedia.com/avatars/member/"+postdata_text[curpost] - [0]+".jpg", "smallavatar": "http://avatars.motherlessmedia.com/avatars/member/"+postdata_text[curpost][0]+"-small.jpg", "post": newpostext}) + re.escape("/") + "([\\w\\/]+)", + r"http://motherless.com/\1", + newpostext) + mlesspostlist.append( + { + "username": postdata_text[curpost][0], + "avatar": "http://avatars.motherlessmedia.com/avatars/member/" + + postdata_text[curpost][0] + + ".jpg", + "smallavatar": "http://avatars.motherlessmedia.com/avatars/member/" + + postdata_text[curpost][0] + + "-small.jpg", + "post": newpostext}) curpost = curpost + 1 - if(post_text > 0): + if (post_text > 0): mlesslink = post_text[0] mlessext = os.path.splitext( urlparse.urlparse(mlesslink).path)[1] mlessext = mlessext.replace(".", "") mlessext = mlessext.lower() - if(mtlessgetargs["id"] == False): + if (mtlessgetargs["id"] == False): mlessfname = urlparse.urlsplit( mlesslink).path.split("/")[-1] - if(mtlessgetargs["id"] == True): + if (mtlessgetargs["id"]): mlessfname = re.sub( - re.escape("/"), "_", mlessid)+"."+mlessext - if(not mlessext == "mp4" and not mlessext == "flv"): + re.escape("/"), "_", mlessid) + "." + mlessext + if (not mlessext == "mp4" and not mlessext == "flv"): imginfo = {} - regex_ii_dimensions = re.escape("style=\"width: ")+"([0-9]+)"+re.escape( - "px; height: ")+"([0-9]+)"+re.escape("px; border: none;\"") + regex_ii_dimensions = re.escape("style=\"width: ") + "([0-9]+)" + re.escape( + "px; height: ") + "([0-9]+)" + re.escape("px; border: none;\"") post_ii_dimensions = re.findall( regex_ii_dimensions, subout_text) post_ii_width = post_ii_dimensions[0][0] post_ii_height = post_ii_dimensions[0][1] - imginfo = {"width": int(post_ii_height), "height": int( - post_ii_width), "views": int(mlessnumviews), "favorites": int(mlessnumfavs)} - if(mlessext == "mp4" or mlessext == "flv"): + imginfo = { + "width": int(post_ii_height), + "height": int(post_ii_width), + "views": int(mlessnumviews), + "favorites": int(mlessnumfavs)} + if (mlessext == "mp4" or mlessext == "flv"): vidinfo = {} - mlesslink = mlesslink+"?start=0" + mlesslink = mlesslink + "?start=0" regex_vi_file = re.escape( - "\"file\" : \"")+"(.*)"+re.escape("\",") + "\"file\" : \"") + "(.*)" + re.escape("\",") post_vi_file = re.findall( regex_vi_file, subout_text) regex_vi_image = re.escape( - "\"image\" : \"")+"(.*)"+re.escape("\",") + "\"image\" : \"") + "(.*)" + re.escape("\",") post_vi_image = re.findall( regex_vi_image, subout_text) regex_vi_height = re.escape( - "\"height\" : ")+"([0-9]+)"+re.escape(",") + "\"height\" : ") + "([0-9]+)" + re.escape(",") post_vi_height = re.findall( regex_vi_height, subout_text) regex_vi_width = re.escape( - "\"width\" : ")+"([0-9]+)"+re.escape(",") + "\"width\" : ") + "([0-9]+)" + re.escape(",") post_vi_width = re.findall( regex_vi_width, subout_text) regex_vi_filethumb = re.escape( - "\"file\": ")+"(.*)"+re.escape(",") + "\"file\": ") + "(.*)" + re.escape(",") post_vi_filethumb = re.findall( regex_vi_filethumb, subout_text) regex_vi_kind = re.escape( - "\"kind\": \"")+"(.*)"+re.escape("\"") + "\"kind\": \"") + "(.*)" + re.escape("\"") post_vi_kind = re.findall( regex_vi_kind, subout_text) - vidinfo = {"file": post_vi_file[0], "image": post_vi_image[0], "width": int(post_vi_width[0]), "height": int(post_vi_height[0]), "views": int(mlessnumviews), "favorites": int( - mlessnumfavs), "filethumb": post_vi_filethumb[0], "thumbstrip": "http://thumbs.motherlessmedia.com/thumbs/"+mlessid+"-strip.jpg", "kind": post_vi_kind[0]} - if(mtlessgetargs["verbose"] == True): + vidinfo = { + "file": post_vi_file[0], + "image": post_vi_image[0], + "width": int( + post_vi_width[0]), + "height": int( + post_vi_height[0]), + "views": int(mlessnumviews), + "favorites": int(mlessnumfavs), + "filethumb": post_vi_filethumb[0], + "thumbstrip": "http://thumbs.motherlessmedia.com/thumbs/" + + mlessid + + "-strip.jpg", + "kind": post_vi_kind[0]} + if (mtlessgetargs["verbose"]): print(mlesslink) mlesslistitms = {} mlesslistitms.update({"id": mlessid}) @@ -523,23 +705,23 @@ def motherless_dl(mtlessgetargs=vars(getargs)): mlesslistitms.update({"servername": servname}) mlesslistitms.update({"servingtime": servsecs}) mlesslistitms.update({"mediatype": mediatype_text[0]}) - if(not mlessext == "mp4" and not mlessext == "flv"): + if (not mlessext == "mp4" and not mlessext == "flv"): mlesslistitms.update({"vidpic": mlesslink}) mlesslistitms.update({"type": "image"}) mlesslistitms.update({"info": imginfo}) mlesslistitms.update( - {"dimensions": str(imginfo["width"])+"x"+str(imginfo["height"])}) + {"dimensions": str(imginfo["width"]) + "x" + str(imginfo["height"])}) mlesslistitms.update({"width": imginfo["width"]}) mlesslistitms.update({"height": imginfo["height"]}) mlesslistitms.update({"views": imginfo["views"]}) mlesslistitms.update( {"favorites": imginfo["favorites"]}) - if(mlessext == "mp4" or mlessext == "flv"): + if (mlessext == "mp4" or mlessext == "flv"): mlesslistitms.update({"vidpic": mlessimg}) mlesslistitms.update({"type": "video"}) mlesslistitms.update({"info": vidinfo}) mlesslistitms.update( - {"dimensions": str(vidinfo["width"])+"x"+str(vidinfo["height"])}) + {"dimensions": str(vidinfo["width"]) + "x" + str(vidinfo["height"])}) mlesslistitms.update({"width": vidinfo["width"]}) mlesslistitms.update({"height": vidinfo["height"]}) mlesslistitms.update({"views": vidinfo["views"]}) @@ -547,70 +729,81 @@ def motherless_dl(mtlessgetargs=vars(getargs)): {"favorites": vidinfo["favorites"]}) mlesslistitms.update({"username": mlessusrname}) mlesslistitms.update( - {"avatar": "http://avatars.motherlessmedia.com/avatars/member/"+mlessusrname+".jpg"}) + {"avatar": "http://avatars.motherlessmedia.com/avatars/member/" + mlessusrname + ".jpg"}) mlesslistitms.update( - {"smallavatar": "http://avatars.motherlessmedia.com/avatars/member/"+mlessusrname+"-small.jpg"}) + { + "smallavatar": "http://avatars.motherlessmedia.com/avatars/member/" + + mlessusrname + + "-small.jpg"}) mlesslistitms.update({"posts": mlesspostlist}) mlesslistitms.update({"pageurl": mlesspurl}) mlesslistitms.update({"url": mlesslink}) mlessoutlist.append(mlesslistitms) - if(curlurl < (numlist - 1)): + if (curlurl < (numlist - 1)): time.sleep(per_url_sleep) curlurl = curlurl + 1 - if(curusrgal < (numusrgal - 1)): + if (curusrgal < (numusrgal - 1)): time.sleep(per_gal_sleep) curusrgal = curusrgal + 1 cururlarg = cururlarg + 1 return mlessoutlist -if(__name__ == "__main__"): +if (__name__ == "__main__"): mtlesslinks = motherless_dl() mtlesslncount = len(mtlesslinks) mtlesscurln = 0 - while(mtlesscurln < mtlesslncount): - if(getargs.get_id == True): + while (mtlesscurln < mtlesslncount): + if (getargs.get_id): print(mtlesslinks[mtlesscurln]["id"]) - if(getargs.get_title == True): + if (getargs.get_title): print(mtlesslinks[mtlesscurln]["title"]) - if(getargs.get_posts == True): + if (getargs.get_posts): numpost = len(mtlesslinks[mtlesscurln]["posts"]) curpost = 0 mlesspostlist = [] - while(numpost > 0 and curpost < numpost): - print(mtlesslinks[mtlesscurln]["posts"][curpost]["username"] + - ": "+mtlesslinks[mtlesscurln]["posts"][curpost]["post"]) + while (numpost > 0 and curpost < numpost): + print( + mtlesslinks[mtlesscurln]["posts"][curpost]["username"] + + ": " + + mtlesslinks[mtlesscurln]["posts"][curpost]["post"]) curpost = curpost + 1 - if(getargs.get_format == True): + if (getargs.get_format): print(mtlesslinks[mtlesscurln]["format"]) - if(getargs.get_type == True): + if (getargs.get_type): print(mtlesslinks[mtlesscurln]["type"]) - if(getargs.get_filename == True): + if (getargs.get_filename): print(mtlesslinks[mtlesscurln]["filename"]) - if(getargs.get_thumbnail == True): + if (getargs.get_thumbnail): print(mtlesslinks[mtlesscurln]["thumbnail"]) - if(mtlesslinks[mtlesscurln]["format"] == "mp4" or mtlesslinks[mtlesscurln]["format"] == "flv"): + if (mtlesslinks[mtlesscurln]["format"] == + "mp4" or mtlesslinks[mtlesscurln]["format"] == "flv"): print(mtlesslinks[mtlesscurln]["vidpic"]) - if(getargs.get_username == True): + if (getargs.get_username): print(mtlesslinks[mtlesscurln]["username"]) - if(getargs.get_pageurl == True): + if (getargs.get_pageurl): print(mtlesslinks[mtlesscurln]["pageurl"]) - if(getargs.get_bbcode == True): - print("[URL="+mtlesslinks[mtlesscurln]["pageurl"]+"][IMG]" + - mtlesslinks[mtlesscurln]["thumbnail"]+"[/IMG][/URL]") - if(getargs.get_html == True): - print("") - if(getargs.get_dimensions == True): + if (getargs.get_bbcode): + print("[URL=" + mtlesslinks[mtlesscurln]["pageurl"] + "][IMG]" + + mtlesslinks[mtlesscurln]["thumbnail"] + "[/IMG][/URL]") + if (getargs.get_html): + print( + "") + if (getargs.get_dimensions): print(mtlesslinks[mtlesscurln]["dimensions"]) - if(getargs.get_width == True): + if (getargs.get_width): print(str(mtlesslinks[mtlesscurln]["width"])) - if(getargs.get_height == True): + if (getargs.get_height): print(str(mtlesslinks[mtlesscurln]["height"])) - if(getargs.get_views == True): + if (getargs.get_views): print(mtlesslinks[mtlesscurln]["views"]) - if(getargs.get_favorites == True): + if (getargs.get_favorites): print(mtlesslinks[mtlesscurln]["favorites"]) - if(getargs.get_url == True or (getargs.get_id == False and getargs.get_title == False and getargs.get_posts == False and getargs.get_format == False and getargs.get_filename == False and getargs.get_thumbnail == False and getargs.get_username == False and getargs.get_pageurl == False and getargs.get_bbcode == False and getargs.get_html == False and getargs.get_dimensions == False and getargs.get_width == False and getargs.get_height == False and getargs.get_views == False and getargs.get_favorites == False and getargs.get_type == False)): + if (getargs.get_url or (getargs.get_id == False and getargs.get_title == False and getargs.get_posts == False and getargs.get_format == False and getargs.get_filename == False and getargs.get_thumbnail == False and getargs.get_username == False and getargs.get_pageurl == + False and getargs.get_bbcode == False and getargs.get_html == False and getargs.get_dimensions == False and getargs.get_width == False and getargs.get_height == False and getargs.get_views == False and getargs.get_favorites == False and getargs.get_type == False)): print(mtlesslinks[mtlesscurln]["url"]) mtlesscurln = mtlesscurln + 1 diff --git a/MiniScripts/videarn-dl.py b/MiniScripts/videarn-dl.py index 2f639a0..17c869c 100755 --- a/MiniScripts/videarn-dl.py +++ b/MiniScripts/videarn-dl.py @@ -16,25 +16,27 @@ $FileInfo: videarn-dl.py - Last Update: 10/07/2013 Ver. 1.0.5 RC 6 - Author: cooldude2k $ ''' -import re +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse parser = argparse.ArgumentParser() parser.add_argument("url", help="videarn url") getargs = parser.parse_args() mlessvid = getargs.url -mregex_text = re.escape("http://videarn.com/video.php?id=")+"([a-zA-Z0-9\/]+)" -if(re.findall(mregex_text, mlessvid)): +mregex_text = re.escape( + "http://videarn.com/video.php?id=") + "([a-zA-Z0-9\\/]+)" +if (re.findall(mregex_text, mlessvid)): mlessvid = re.findall(mregex_text, mlessvid) mlessvid = mlessvid[0] fakeua = "Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Firefox/24.0"" diff --git a/PyClock/bin/clock.py b/PyClock/bin/clock.py index 5dd762f..9ce33c0 100644 --- a/PyClock/bin/clock.py +++ b/PyClock/bin/clock.py @@ -15,40 +15,43 @@ $FileInfo: clock.py - Last Update: 05/11/2012 Ver 1.0.0-10 - Author: cooldude2k $ """ +import calendar +import glob +import locale import os +import platform +import shutil import sys import time -import locale -import calendar -import pygame -import platform -import glob -from os import environ, system, mkdir -from sys import version, exit -from time import gmtime, strftime from glob import glob +from os import environ, mkdir, system +from sys import exit, version +from time import gmtime, strftime + +import pygame from pygame import init, quit from pygame.locals import * -import shutil pythonver = version -print('python version "'+pythonver+'"') -print('system: "%s"\nnode: "%s"\nrelease: "%s"\nversion: "%s"\nmachine: "%s"\nprocessor: "%s"' % platform.uname()) +print('python version "' + pythonver + '"') +print( + 'system: "%s"\nnode: "%s"\nrelease: "%s"\nversion: "%s"\nmachine: "%s"\nprocessor: "%s"' % + platform.uname()) init() print('init pygame') fpsclock = pygame.time.Clock() pygamever = pygame.version.ver -print('pygame version '+pygamever) +print('pygame version ' + pygamever) print('sdl version %s.%s.%s' % pygame.get_sdl_version()) -if(os.path.exists('./config.txt') == True): - if(os.path.isdir('./config.txtt') == True): +if (os.path.exists('./config.txt')): + if (os.path.isdir('./config.txtt')): os.removedirs('./config.txt') print('deleting file "./config.txt"') -if(os.path.exists('./config.txt') == False): +if (os.path.exists('./config.txt') == False): shutil.copyfile('./default/config.txt', './config.txt') print('copying config file "./default/config.txt" to "./config.txt"') -if(os.path.exists('./screenshots') == False): +if (os.path.exists('./screenshots') == False): mkdir('./screenshots') print('making screenshot dir "./screenshots"') @@ -84,14 +87,14 @@ numtzs = len(pytimezonesplit) currenttz = 0 environ['SDL_VIDEODRIVER'] = 'x11' pygame.display.init() -print('init pygame '+pygame.display.get_driver()+' display') +print('init pygame ' + pygame.display.get_driver() + ' display') pyicon = pygame.image.load('./icon.png') pygame.display.set_icon(pyicon) globfiles = glob(pysoundfiles) numfiles = len(globfiles) countnum = 0 -if(numfiles > 0): +if (numfiles > 0): print('number of sound files %i' % numfiles) pygame.mixer.init(int(pysndconfsplit[0]), int(pysndconfsplit[1]), int( pysndconfsplit[2]), int(pysndconfsplit[3])) @@ -100,7 +103,12 @@ if(numfiles > 0): print('supported display modes "%s"' % pygame.display.list_modes()) pyscreen = pygame.display.set_mode( (int(displaysizesplit[0]), int(displaysizesplit[1])), FULLSCREEN) -print('setting display mode "'+displaysizesplit[0]+'x'+displaysizesplit[1]+'"') +print( + 'setting display mode "' + + displaysizesplit[0] + + 'x' + + displaysizesplit[1] + + '"') print('setting fullscreen mode') pybackground = pygame.Surface(pyscreen.get_size()) pybackground.fill((int(bgcsplit[0]), int(bgcsplit[1]), int(bgcsplit[2]))) @@ -119,26 +127,28 @@ while not done: pyscreen.fill((int(bgcsplit[0]), int(bgcsplit[1]), int(bgcsplit[2]))) fcount0 = 0 while (fcount0 < len(imgbgsplit)): - if (os.path.exists(imgbgsplit[int(fcount0)]) == True): + if (os.path.exists(imgbgsplit[int(fcount0)])): pybgimgall = {} - if(fcountall == 0): + if (fcountall == 0): print('loading background image "' + - imgbgsplit[int(fcount0)]+'"') + imgbgsplit[int(fcount0)] + '"') print('setting background image "' + - imgbgsplit[int(fcount0)]+'"') + imgbgsplit[int(fcount0)] + '"') pybgimgall[int(fcount0)] = pygame.image.load( imgbgsplit[int(fcount0)]) pybgimgxyall = imgbgxysplit[int(fcount0)].split(',') pyscreen.blit(pybgimgall[int(fcount0)], (int( pybgimgxyall[0]), int(pybgimgxyall[1]))) fcount0 = fcount0 + 1 - if(pytimezonesplit[currenttz] != "System" and oldtz != pytimezonesplit[currenttz]): + if (pytimezonesplit[currenttz] != + "System" and oldtz != pytimezonesplit[currenttz]): oldtz = pytimezonesplit[currenttz] - #os.environ['TZ'] = 'UTC'; - print('setting timezone to "'+pytimezonesplit[currenttz]+'"') + # os.environ['TZ'] = 'UTC'; + print('setting timezone to "' + pytimezonesplit[currenttz] + '"') os.putenv('TZ', pytimezonesplit[currenttz]) # time.tzset(); - if(pytimezonesplit[currenttz] == "System" and oldtz != pytimezonesplit[currenttz]): + if (pytimezonesplit[currenttz] == + "System" and oldtz != pytimezonesplit[currenttz]): oldtz = pytimezonesplit[currenttz] print('setting timezone to system time') os.unsetenv('TZ') @@ -152,9 +162,9 @@ while not done: pyfontall[int(fcount1)].set_bold(int(fontsizeall[1])) pyfontall[int(fcount1)].set_italic(int(fontsizeall[2])) pyfontall[int(fcount1)].set_underline(int(fontsizeall[3])) - if(fcountall == 0): - print('loading font file "'+fontloadsplit[int(fcount1)]+'"') - print('setting font size '+fontsizeall[0]) + if (fcountall == 0): + print('loading font file "' + fontloadsplit[int(fcount1)] + '"') + print('setting font size ' + fontsizeall[0]) pycolorall = pycolorsplit[int(fcount1)].split(',') fontxyall = fontxysplit[int(fcount1)].split(',') pytimeall = {} @@ -163,17 +173,17 @@ while not done: pyscreen.blit(pytimeall[int(fcount1)], (int(fontxyall[0]), int(fontxyall[1]))) fcount1 = fcount1 + 1 - if(numfiles > 0): - if(pygame.mixer.music.get_busy() == 0): + if (numfiles > 0): + if (pygame.mixer.music.get_busy() == 0): pysound = pygame.mixer.music.load(globfiles[int(countnum)]) - print('loading music file "'+globfiles[int(countnum)]+'"') + print('loading music file "' + globfiles[int(countnum)] + '"') pygame.mixer.music.set_volume(float(pysndconfsplit[4])) print('setting sound volume %f' % float(pysndconfsplit[4])) pygame.mixer.music.play(0) - print('playing music file "'+globfiles[int(countnum)]+'"') - if(countnum < numfiles): + print('playing music file "' + globfiles[int(countnum)] + '"') + if (countnum < numfiles): countnum = countnum + 1 - if(countnum == numfiles): + if (countnum == numfiles): countnum = 0 pygame.display.update() fpsclock.tick(30) @@ -183,40 +193,52 @@ while not done: if (event.type == pygame.KEYDOWN): if (event.key == pygame.K_SPACE) and (numfiles > 0): pygame.mixer.music.stop() - print('stoping sound file "'+globfiles[int(countnum)]+'"') + print('stoping sound file "' + globfiles[int(countnum)] + '"') pygame.mixer.stop() print('stoping all sounds') if (event.key == pygame.K_LALT) or (event.key == pygame.K_RALT): saveimgnum = 0 imgdone = False while not imgdone: - if (os.path.exists('./screenshots/screenshot_%i.jpg' % saveimgnum) == False): + if (os.path.exists('./screenshots/screenshot_%i.jpg' % + saveimgnum) == False): pygame.image.save( - pyscreen, './screenshots/screenshot_%i.jpg' % saveimgnum) + pyscreen, + './screenshots/screenshot_%i.jpg' % + saveimgnum) print( - 'saving screenshot at file "./screenshots/screenshot_%i.jpg"' % saveimgnum) + 'saving screenshot at file "./screenshots/screenshot_%i.jpg"' % + saveimgnum) imgdone = True saveimgnum = saveimgnum + 1 if (event.key == pygame.K_PRINT): saveimgnum = 0 imgdone = False while not imgdone: - if (os.path.exists('./screenshots/screenshot_%i.bmp' % saveimgnum) == False): + if (os.path.exists('./screenshots/screenshot_%i.bmp' % + saveimgnum) == False): pygame.image.save( - pyscreen, './screenshots/screenshot_%i.bmp' % saveimgnum) + pyscreen, + './screenshots/screenshot_%i.bmp' % + saveimgnum) print( - 'saving screenshot at file "./screenshots/screenshot_%i.bmp"' % saveimgnum) + 'saving screenshot at file "./screenshots/screenshot_%i.bmp"' % + saveimgnum) imgdone = True saveimgnum = saveimgnum + 1 if (event.key == pygame.K_LCTRL) or (event.key == pygame.K_RCTRL): saveimgnum = 0 imgdone = False while not imgdone: - if (os.path.exists('./screenshots/screenshot_%i.png' % saveimgnum) == False): + if (os.path.exists('./screenshots/screenshot_%i.png' % + saveimgnum) == False): pygame.image.save( - pyscreen, './screenshots/screenshot_%i.png' % saveimgnum) + pyscreen, + './screenshots/screenshot_%i.png' % + saveimgnum) print( - 'saving screenshot at file "./screenshots/screenshot_%i.png"' % saveimgnum) + 'saving screenshot at file "./screenshots/screenshot_%i.png"' % + saveimgnum) imgdone = True saveimgnum = saveimgnum + 1 if (event.key == pygame.K_t) or (event.key == pygame.K_w): @@ -226,22 +248,22 @@ while not done: pygame.display.iconify() print('minimizing window to system tray') if (event.key == pygame.K_LEFT): - if(currenttz == 0): + if (currenttz == 0): currenttz = numtzs - if(currenttz > 0): + if (currenttz > 0): currenttz = currenttz - 1 if (event.key == pygame.K_RIGHT): - if(currenttz < numtzs): + if (currenttz < numtzs): currenttz = currenttz + 1 - if(currenttz == numtzs): + if (currenttz == numtzs): currenttz = 0 if (event.key == pygame.K_ESCAPE) or (event.key == pygame.K_q): done = True -if(numfiles > 0): +if (numfiles > 0): pygame.mixer.music.stop() - print('stoping music file "'+globfiles[int(countnum)]+'"') + print('stoping music file "' + globfiles[int(countnum)] + '"') pygame.mixer.stop() print('stoping all sounds') pygame.mixer.quit() diff --git a/PyXV/xv-alt.py b/PyXV/xv-alt.py index ebad0e6..fd9a8e8 100755 --- a/PyXV/xv-alt.py +++ b/PyXV/xv-alt.py @@ -14,21 +14,22 @@ $FileInfo: xv-alt.py - Last Update: 04/01/2013 Ver. 1.0.0 - Author: cooldude2k $ ''' +import argparse import os import sys + import pygame -import argparse parser = argparse.ArgumentParser() parser.add_argument("-name", help="title name") parser.add_argument("file", help="file name") getargs = parser.parse_args() -if(getargs.file != None): +if (getargs.file is not None): pygame.display.quit() pygame.quit() sys.exit(0) -if(not os.path.exists(getargs.file) or not os.path.isfile(getargs.file)): +if (not os.path.exists(getargs.file) or not os.path.isfile(getargs.file)): pygame.display.quit() pygame.quit() sys.exit(0) @@ -39,10 +40,10 @@ pygame.display.set_icon(pyicon) ppmimg = pygame.image.load(getargs.file) width, height = ppmimg.get_size() screen = pygame.display.set_mode((width, height)) -if(getargs.name != None): - pygame.display.set_caption("PyXV - "+str(getargs.name)) -if(getargs.name == None): - pygame.display.set_caption("PyXV - "+str(os.path.basename(getargs.file))) +if (getargs.name is not None): + pygame.display.set_caption("PyXV - " + str(getargs.name)) +if (getargs.name is None): + pygame.display.set_caption("PyXV - " + str(os.path.basename(getargs.file))) pygame.display.get_active() pygame.mouse.set_visible(0) diff --git a/PyXV/xv-dl.py b/PyXV/xv-dl.py index baba192..174d328 100644 --- a/PyXV/xv-dl.py +++ b/PyXV/xv-dl.py @@ -14,67 +14,87 @@ $FileInfo: xv.py - Last Update: 04/01/2013 Ver. 1.0.0 - Author: cooldude2k $ ''' -from __future__ import division, absolute_import, print_function -import re +from __future__ import absolute_import, division, print_function + +import argparse +import datetime +import gzip import os +import re import sys +import time import urllib -import urllib2 + import cookielib +import pygame import StringIO -import gzip -import time -import datetime -import argparse +import urllib2 import urlparse -import pygame parser = argparse.ArgumentParser() parser.add_argument("-name", help="title name") parser.add_argument("file", nargs="*", help="file name") -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( + "--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") getargs = parser.parse_args() 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;q=0.8,en-CA,en-GB;q=0.6"), - ("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")] -if(getargs.file == None or len(getargs.file) == 0): +geturls_opener.addheaders = [ + ("Referer", + getargs.referer), + ("User-Agent", + fakeua), + ("Accept-Encoding", + "gzip, deflate"), + ("Accept-Language", + "en-US,en;q=0.8,en-CA,en-GB;q=0.6"), + ("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")] +if (getargs.file is None or len(getargs.file) == 0): pygame.display.quit() pygame.quit() sys.exit(0) numurlarg = len(getargs.file) cururlarg = 0 -while(cururlarg < numurlarg): +while (cururlarg < numurlarg): geturls_text = geturls_opener.open(getargs.file[cururlarg]) - if(geturls_text.info().get("Content-Encoding") == "gzip" or geturls_text.info().get("Content-Encoding") == "deflate"): + 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) outbuf = StringIO.StringIO(gzstrbuf.read()[:]) - if(geturls_text.info().get("Content-Encoding") != "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): + if (geturls_text.info().get("Content-Encoding") != + "gzip" and geturls_text.info().get("Content-Encoding") != "deflate"): outbuf = StringIO.StringIO(geturls_text.read()[:]) pygame.display.init() pyres = (pygame.display.Info().current_h, pygame.display.Info().current_w) ppmimg = pygame.image.load(outbuf) width, height = ppmimg.get_size() - if(width > pyres[0] or height > pyres[1]): + if (width > pyres[0] or height > pyres[1]): dest_w = float(pyres[0]) dest_h = float(pyres[1]) scale = dest_w / width - if(height*scale > dest_h): + if (height * scale > dest_h): scale = dest_h / height size = (int(width * scale), int(height * scale)) width = size[0] height = size[1] ppmimg = pygame.transform.scale(ppmimg, (width, height)) screen = pygame.display.set_mode((width, height)) - if(getargs.name != None): - pygame.display.set_caption("PyXV - "+str(getargs.name)) - if(getargs.name == None): - pygame.display.set_caption("PyXV - "+str(getargs.file[cururlarg])) + if (getargs.name is not None): + pygame.display.set_caption("PyXV - " + str(getargs.name)) + if (getargs.name is None): + pygame.display.set_caption("PyXV - " + str(getargs.file[cururlarg])) pygame.display.get_active() pygame.mouse.set_visible(0) screen.blit(ppmimg, (0, 0)) diff --git a/PyXV/xv.py b/PyXV/xv.py index ea4156f..73991d1 100755 --- a/PyXV/xv.py +++ b/PyXV/xv.py @@ -16,21 +16,22 @@ ''' import os import sys + import pygame pygame.display.init() pyicon = pygame.image.load("/mnt/utmp/upctest/old_icon.png") pygame.display.set_icon(pyicon) -if(len(sys.argv) == 2): +if (len(sys.argv) == 2): ppmimg = pygame.image.load(sys.argv[1]) -if(len(sys.argv) == 4): +if (len(sys.argv) == 4): ppmimg = pygame.image.load(sys.argv[3]) width, height = ppmimg.get_size() screen = pygame.display.set_mode((width, height)) -if(len(sys.argv) == 2): - pygame.display.set_caption("PyXV - "+str(os.path.basename(sys.argv[1]))) -if(len(sys.argv) == 4): - pygame.display.set_caption("PyXV - "+str(sys.argv[2])) +if (len(sys.argv) == 2): + pygame.display.set_caption("PyXV - " + str(os.path.basename(sys.argv[1]))) +if (len(sys.argv) == 4): + pygame.display.set_caption("PyXV - " + str(sys.argv[2])) pygame.display.get_active() pygame.mouse.set_visible(0) -- 2.11.4.GIT