4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the Revised BSD License.
7 This program is distributed in the hope that it will be useful,
8 but WITHOUT ANY WARRANTY; without even the implied warranty of
9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 Revised BSD License for more details.
12 Copyright 2016 Cool Dude 2k - http://idb.berlios.de/
13 Copyright 2016 Game Maker 2k - http://intdb.sourceforge.net/
14 Copyright 2016 Kazuki Przyborowski - https://github.com/KazukiPrzyborowski
16 $FileInfo: pymotherless.py - Last Update: 1/22/2016 Ver. 0.3.1 RC 2 - Author: cooldude2k $
19 from __future__
import division
, absolute_import
, print_function
;
20 import re
, os
, sys
, urllib
, gzip
, time
, datetime
, argparse
, cgi
, subprocess
;
21 if(sys
.version
[0]=="2"):
23 from cStringIO
import StringIO
;
25 from StringIO
import StringIO
;
26 import urllib2
, urlparse
, cookielib
;
27 if(sys
.version
[0]=="3"):
28 from io
import StringIO
, BytesIO
;
29 import urllib
.request
as urllib2
;
30 import urllib
.parse
as urlparse
;
31 import http
.cookiejar
as cookielib
;
32 if(__name__
== "__main__"):
33 sys
.tracebacklimit
= 0;
34 __program_name__
= "PyMotherless";
35 __version_info__
= (0, 3, 1, "RC 2");
36 __version_date__
= "2016.01.19";
37 __version_date_plusrc__
= "2016.01.19-2";
38 if(__version_info__
[3]!=None):
39 __version__
= str(__version_info__
[0])+"."+str(__version_info__
[1])+"."+str(__version_info__
[2])+" "+str(__version_info__
[3]);
40 if(__version_info__
[3]==None):
41 __version__
= str(__version_info__
[0])+"."+str(__version_info__
[1])+"."+str(__version_info__
[2]);
43 geturls_cj
= cookielib
.CookieJar();
44 geturls_ua_firefox_windows7
= "Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0";
45 geturls_ua_chrome_windows7
= "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36";
46 geturls_ua_internet_explorer_windows7
= "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko";
47 geturls_ua
= geturls_ua_firefox_windows7
;
48 geturls_headers
= [("Referer", "http://motherless.com/"), ("User-Agent", geturls_ua
), ("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")];
49 geturls_download_sleep
= 0;
51 def add_url_param(url
, **params
):
53 parts
= list(urlparse
.urlsplit(url
));
54 d
= dict(cgi
.parse_qsl(parts
[n
])); # use cgi.parse_qs for list values
56 parts
[n
]=urllib
.urlencode(d
);
57 return urlparse
.urlunsplit(parts
);
59 os
.environ
["PATH"] = os
.environ
["PATH"] + os
.pathsep
+ os
.path
.dirname(os
.path
.realpath(__file__
)) + os
.pathsep
+ os
.getcwd();
60 def which_exec(execfile):
61 for path
in os
.environ
["PATH"].split(":"):
62 if os
.path
.exists(path
+ "/" + execfile):
63 return path
+ "/" + execfile;
73 newlistreg
.update({ilx
: varlist
[il
]});
74 newlistrev
.update({varlist
[il
]: ilx
});
77 newlistfull
= {1: newlistreg
, 2: newlistrev
, 'reg': newlistreg
, 'rev': newlistrev
};
80 def twolistize(varlist
):
90 newlistnamereg
.update({ilx
: varlist
[il
][0].strip()});
91 newlistnamerev
.update({varlist
[il
][0].strip(): ilx
});
92 newlistdescreg
.update({ilx
: varlist
[il
][1].strip()});
93 newlistdescrev
.update({varlist
[il
][1].strip(): ilx
});
96 newlistnametmp
= {1: newlistnamereg
, 2: newlistnamerev
, 'reg': newlistnamereg
, 'rev': newlistnamerev
};
97 newlistdesctmp
= {1: newlistdescreg
, 2: newlistdescrev
, 'reg': newlistdescreg
, 'rev': newlistdescrev
};
98 newlistfull
= {1: newlistnametmp
, 2: newlistdesctmp
, 'name': newlistnametmp
, 'desc': newlistdesctmp
}
101 def arglistize(proexec
, *varlist
):
105 newarglist
= [proexec
];
107 if varlist
[il
][0] is not None:
108 newarglist
.append(varlist
[il
][0]);
109 if varlist
[il
][1] is not None:
110 newarglist
.append(varlist
[il
][1]);
114 def make_http_headers_from_dict(headers
={'Referer': "http://motherless.com/", 'User-Agent': geturls_ua
, '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"}):
116 for headkey
, headvalue
in headers
.iteritems():
117 returnval
.append((headkey
, headvalue
));
120 def download_from_url(httpurl
, httpheaders
, httpcookie
, sleep
=-1):
121 global geturls_download_sleep
;
123 sleep
= geturls_download_sleep
;
124 geturls_opener
= urllib2
.build_opener(urllib2
.HTTPCookieProcessor(httpcookie
));
125 geturls_opener
.addheaders
= httpheaders
;
127 geturls_text
= geturls_opener
.open(httpurl
);
128 if(geturls_text
.info().get("Content-Encoding")=="gzip" or geturls_text
.info().get("Content-Encoding")=="deflate"):
129 if(sys
.version
[0]=="2"):
130 strbuf
= StringIO(geturls_text
.read());
131 if(sys
.version
[0]=="3"):
132 strbuf
= BytesIO(geturls_text
.read());
133 gzstrbuf
= gzip
.GzipFile(fileobj
=strbuf
);
134 if(sys
.version
[0]=="2"):
135 returnval
= gzstrbuf
.read()[:];
136 if(sys
.version
[0]=="3"):
137 returnval
= gzstrbuf
.read()[:].decode('ascii', 'replace');
138 if(geturls_text
.info().get("Content-Encoding")!="gzip" and geturls_text
.info().get("Content-Encoding")!="deflate"):
139 returnval
= geturls_text
.read()[:];
142 def download_from_url_file(httpurl
, httpheaders
, httpcookie
, sleep
=-1):
143 global geturls_download_sleep
;
145 sleep
= geturls_download_sleep
;
146 geturls_opener
= urllib2
.build_opener(urllib2
.HTTPCookieProcessor(httpcookie
));
147 geturls_opener
.addheaders
= httpheaders
;
149 geturls_text
= geturls_opener
.open(httpurl
);
150 if(geturls_text
.info().get("Content-Encoding")=="gzip" or geturls_text
.info().get("Content-Encoding")=="deflate"):
151 if(sys
.version
[0]=="2"):
152 strbuf
= StringIO(geturls_text
.read());
153 if(sys
.version
[0]=="3"):
154 strbuf
= BytesIO(geturls_text
.read());
155 gzstrbuf
= gzip
.GzipFile(fileobj
=strbuf
);
156 returnval
= gzstrbuf
.read()[:];
157 if(geturls_text
.info().get("Content-Encoding")!="gzip" and geturls_text
.info().get("Content-Encoding")!="deflate"):
158 returnval
= geturls_text
.read()[:];
161 def download_from_url_to_file(httpurl
, httpheaders
, httpcookie
, outfile
="-", outpath
=os
.getcwd(), sleep
=-1):
162 global geturls_download_sleep
;
164 sleep
= geturls_download_sleep
;
165 if(not outfile
=="-"):
166 outpath
= outpath
.rstrip(os
.path
.sep
);
167 filepath
= os
.path
.realpath(outpath
+os
.path
.sep
+outfile
);
168 if(not os
.path
.exists(outpath
)):
169 os
.makedirs(outpath
);
170 if(os
.path
.exists(outpath
) and os
.path
.isfile(outpath
)):
172 if(os
.path
.exists(filepath
) and os
.path
.isdir(filepath
)):
174 with
open(filepath
, 'wb+') as f
:
175 f
.write(download_from_url_file(httpurl
, httpheaders
, httpcookie
, sleep
));
178 if(outfile
=="-" and sys
.version
[0]=="2"):
180 f
.write(download_from_url_file(httpurl
, httpheaders
, httpcookie
, sleep
));
181 returnval
= f
.getvalue();
183 if(outfile
=="-" and sys
.version
[0]=="3"):
185 f
.write(download_from_url_file(httpurl
, httpheaders
, httpcookie
, sleep
));
186 returnval
= f
.getvalue();
190 def get_motherless_get_number_pages(httpurl
, httpheaders
, httpcookie
):
191 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
192 mregex_getpagenum
= re
.escape("page=")+"([0-9]+)"+re
.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re
.escape("\">")+"([0-9]+)"+re
.escape("</a>");
193 mlesspagenum
= re
.findall(mregex_getpagenum
, mrtext
);
195 returnval
= mlesspagenum
[-1][0];
200 def get_motherless_get_link_type(httpurl
):
201 mlessvidqstr
= urlparse
.parse_qs(urlparse
.urlparse(httpurl
).query
);
202 mlessvidid_parts
= urlparse
.urlparse(httpurl
);
203 mlessvidid
= mlessvidid_parts
.path
.split("/");
205 if(mlessvidid
[1]=="videos" and len(mlessvidid
)==3 and (mlessvidid
[2]=="recent" or mlessvidid
[2]=="favorited" or mlessvidid
[2]=="viewed" or mlessvidid
[2]=="commented" or mlessvidid
[2]=="popular")):
206 returnval
= "gallery";
207 if(mlessvidid
[1]=="images" and len(mlessvidid
)==3 and (mlessvidid
[2]=="recent" or mlessvidid
[2]=="favorited" or mlessvidid
[2]=="viewed" or mlessvidid
[2]=="commented" or mlessvidid
[2]=="popular")):
208 returnval
= "gallery";
209 if(mlessvidid
[1]=="galleries" and len(mlessvidid
)==3 and (mlessvidid
[2]=="recent" or mlessvidid
[2]=="favorited" or mlessvidid
[2]=="viewed" or mlessvidid
[2]=="commented" or mlessvidid
[2]=="popular")):
210 returnval
= "gallery";
211 if(mlessvidid
[1]=="videos" and len(mlessvidid
)==2):
212 returnval
= "sample-videos";
213 if(mlessvidid
[1]=="images" and len(mlessvidid
)==2):
214 returnval
= "sample-images";
215 if(mlessvidid
[1]=="galleries" and len(mlessvidid
)==2):
216 returnval
= "sample-galleries";
217 if(mlessvidid
[1]=="" and len(mlessvidid
)==2):
218 returnval
= "sample";
219 if(mlessvidid
[1]=="live" and len(mlessvidid
)==3 and (mlessvidid
[2]=="videos" or mlessvidid
[2]=="images")):
220 returnval
= "gallery";
221 if(mlessvidid
[1]=="u" and len(mlessvidid
)==3):
222 returnval
= "gallery";
223 if(mlessvidid
[1]=="f" and len(mlessvidid
)==4 and (mlessvidid
[2]=="videos" or mlessvidid
[2]=="images" or mlessvidid
[2]=="galleries")):
224 returnval
= "gallery";
225 if(mlessvidid
[1]=="galleries" and len(mlessvidid
)==4 and mlessvidid
[2]=="member"):
226 returnval
= "gallery";
227 if(mlessvidid
[1]=="galleries" and len(mlessvidid
)==5 and mlessvidid
[2]=="member" and (mlessvidid
[4]=="created" or mlessvidid
[4]=="viewed" or mlessvidid
[4]=="favorited" or mlessvidid
[4]=="commented")):
228 returnval
= "gallery";
229 if(mlessvidid
[1]=="gv" and len(mlessvidid
)==3):
230 returnval
= "gallery";
231 if(mlessvidid
[1]=="gi" and len(mlessvidid
)==3):
232 returnval
= "gallery";
233 if(mlessvidid
[1]=="term" and len(mlessvidid
)==3 and (mlessvidid
[2]=="videos" or mlessvidid
[2]=="images" or mlessvidid
[2]=="galleries")):
234 returnval
= "gallery";
235 if(mlessvidid
[1]=="g" and len(mlessvidid
)==4):
237 if(mlessvidid
[1]=="random" and len(mlessvidid
)==3 and (mlessvidid
[2]=="video" or mlessvidid
[2]=="image")):
239 if(re
.match("^V", mlessvidid
[1]) and len(mlessvidid
)==2):
241 if(mlessvidid
[1]=="members" and len(mlessvidid
)==2):
242 returnval
= "member";
243 if(mlessvidid
[1]=="members" and mlessvidid
[2]=="search" and len(mlessvidid
)==3):
244 returnval
= "member";
245 if(mlessvidid
[1]=="members" and len(mlessvidid
)==4 and (mlessvidid
[2]=="uploader" or mlessvidid
[2]=="viewed" or mlessvidid
[2]=="social" or mlessvidid
[2]=="favorited" or mlessvidid
[2]=="commented" or mlessvidid
[2]=="mentioned" or mlessvidid
[2]=="verified")):
246 returnval
= "member";
247 if(mlessvidid
[1]=="girls" and len(mlessvidid
)==2):
249 if(mlessvidid
[1]=="referers" and len(mlessvidid
)==2):
250 returnval
= "referers";
251 if(mlessvidid
[1]=="about" and len(mlessvidid
)==2):
253 if(mlessvidid_parts
.netloc
=="cdn.images.motherlessmedia.com" or mlessvidid_parts
.netloc
=="cdn.videos.motherlessmedia.com" or mlessvidid_parts
.netloc
=="cdn.thumbs.motherlessmedia.com"):
254 returnval
= "download";
255 if(returnval
==False and len(mlessvidid
)==2):
259 def get_motherless_links(httpurl
, httpheaders
, httpcookie
):
260 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
261 mregex_gettitle
= re
.escape("<title>")+"(.*)"+re
.escape(" - MOTHERLESS.COM</title>");
262 mlesstitle
= re
.findall(mregex_gettitle
, mrtext
);
263 mregex_geturlone
= re
.escape("__fileurl = 'http://cdn.")+"(images|videos)"+re
.escape(".motherlessmedia.com/")+"(images|videos)"+re
.escape("/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("';");
264 mlesslinkone
= re
.findall(mregex_geturlone
, mrtext
);
265 mregex_geturltwo
= re
.escape("<meta property=\"og:image\" content=\"http://cdn.")+"(images|thumbs)"+re
.escape(".motherlessmedia.com/")+"(images|thumbs)"+re
.escape("/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\">");
266 mlesslinktwo
= re
.findall(mregex_geturltwo
, mrtext
);
267 filenameext
= os
.path
.basename(urlparse
.urljoin("http://cdn."+mlesslinkone
[0][0]+".motherlessmedia.com/"+mlesslinkone
[0][1]+"/"+mlesslinkone
[0][2], urlparse
.urlparse("http://cdn."+mlesslinkone
[0][0]+".motherlessmedia.com/"+mlesslinkone
[0][1]+"/"+mlesslinkone
[0][2]).path
));
268 filename
, fileextension
= os
.path
.splitext(filenameext
);
269 thumbfilenameext
= os
.path
.basename(urlparse
.urljoin("http://cdn.images.motherlessmedia.com/"+mlesslinktwo
[0][1]+"/"+mlesslinktwo
[0][2], urlparse
.urlparse("http://cdn.images.motherlessmedia.com/"+mlesslinktwo
[0][1]+"/"+mlesslinktwo
[0][2]).path
));
270 thumbfilename
, thumbfileextension
= os
.path
.splitext(thumbfilenameext
);
271 mregex_getuname
= re
.escape("<tr rel=\"")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\"");
272 mlessuname
= re
.findall(mregex_getuname
, mrtext
);
273 mlessuname
= mlessuname
[0];
274 mregex_geturlname
= re
.escape("<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" target=\"_blank\">\n <img");
275 mlessurlname
= re
.findall(mregex_geturlname
, mrtext
);
276 mlessurlname
= mlessurlname
[0];
277 mregex_getavatar
= re
.escape("<img\n src=\"")+"(.*)"+re
.escape("\"\n class=\"avatar avatar-small\"");
278 mlessavatar
= re
.findall(mregex_getavatar
, mrtext
);
279 mlessavatar
= mlessavatar
[0];
280 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin(mlessavatar
, urlparse
.urlparse(mlessavatar
).path
));
281 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
282 if(mlesslinkone
[0][1]=="images"):
283 thumbnailaltpart
= thumbfilename
+"-zoom"+thumbfileextension
;
284 thumbnailalt
= "http://cdn.thumbs.motherlessmedia.com/thumbs/"+thumbnailaltpart
;
285 thumbnailaltfilenameext
= os
.path
.basename(urlparse
.urljoin(thumbnailalt
, urlparse
.urlparse(thumbnailalt
).path
));
286 thumbnailaltfilename
, thumbnailaltfileextension
= os
.path
.splitext(thumbnailaltfilenameext
);
287 if(mlesslinkone
[0][1]=="videos"):
288 thumbnailaltpart
= thumbfilename
+"-small"+thumbfileextension
;
289 thumbnailalt
= "http://cdn.thumbs.motherlessmedia.com/thumbs/"+thumbnailaltpart
;
290 thumbnailaltfilenameext
= os
.path
.basename(urlparse
.urljoin(thumbnailalt
, urlparse
.urlparse(thumbnailalt
).path
));
291 thumbnailaltfilename
, thumbnailaltfileextension
= os
.path
.splitext(thumbnailaltfilenameext
);
293 mlessurltype
= get_motherless_get_link_type("http://cdn."+mlesslinkone
[0][0]+".motherlessmedia.com/"+mlesslinkone
[0][1]+"/"+mlesslinkone
[0][2]);
294 if(mlesslinkone
[0][1]=="images"):
295 returnval
= {'type': mlesslinkone
[0][1], 'urltype': mlessurltype
, 'url': "http://cdn."+mlesslinkone
[0][0]+".motherlessmedia.com/"+mlesslinkone
[0][1]+"/"+mlesslinkone
[0][2], 'orginurl': httpurl
, 'orginurltype': get_motherless_get_link_type(httpurl
), 'thumbnail': "http://cdn.thumbs.motherlessmedia.com/thumbs/"+mlesslinktwo
[0][2], 'thumbnailalt': thumbnailalt
+"?from_helper", 'title': mlesstitle
[0], 'fullfilename': filenameext
, 'filename': filename
, 'extension': fileextension
, 'thumbfullfilename': thumbfilenameext
, 'thumbfilename': thumbfilename
, 'thumbextension': thumbfileextension
, 'thumbnailaltfullfilename': thumbnailaltpart
, 'thumbnailaltfilename': thumbnailaltfilename
, 'thumbnailaltextension': thumbnailaltfileextension
, 'username': mlessuname
, 'avatarurl': mlessavatar
, 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
};
296 if(mlesslinkone
[0][1]=="videos"):
297 returnval
= {'type': mlesslinkone
[0][1], 'url': "http://cdn."+mlesslinkone
[0][0]+".motherlessmedia.com/"+mlesslinkone
[0][1]+"/"+mlesslinkone
[0][2], 'orginurl': httpurl
, 'orginurltype': get_motherless_get_link_type(httpurl
), 'thumbnail': "http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[0][1]+"/"+mlesslinktwo
[0][2], 'thumbnailalt': thumbnailalt
+"?from_helper", 'title': mlesstitle
[0], 'fullfilename': filenameext
, 'filename': filename
, 'extension': fileextension
, 'thumbfullfilename': thumbfilenameext
, 'thumbfilename': thumbfilename
, 'thumbextension': thumbfileextension
, 'thumbnailaltfullfilename': thumbnailaltpart
, 'thumbnailaltfilename': thumbnailaltfilename
, 'thumbnailaltextension': thumbnailaltfileextension
, 'username': mlessuname
, 'avatarurl': mlessavatar
, 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
};
300 def get_motherless_galleries_links(httpurl
, httpheaders
, httpcookie
, page
=1, getlinks
=[0, -1]):
301 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
302 mregex_getpagenum
= re
.escape("page=")+"([0-9]+)"+re
.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re
.escape("\">")+"([0-9]+)"+re
.escape("</a>");
303 mlesspagenum
= re
.findall(mregex_getpagenum
, mrtext
);
305 lastpage
= mlesspagenum
[-1][0];
310 httpurl
= add_url_param(httpurl
, page
=str(page
));
311 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
312 mregex_geturlone
= re
.escape("<a href=\"/")+"([\w\/]+)"+re
.escape("\" class=\"img-container\" target=\"_self\">");
313 mrtext_tmp
= re
.sub(re
.escape("http://motherless.com"), "", mrtext
);
314 mrtext_tmp
= re
.sub(re
.escape("http://www.motherless.com"), "", mrtext_tmp
);
315 mrtext_tmp
= re
.sub(re
.escape("http://motherless.com"), "", mrtext_tmp
);
316 mrtext_tmp
= re
.sub(re
.escape("http://www.motherless.com"), "", mrtext_tmp
);
317 mlesslinkone
= re
.findall(mregex_geturlone
, mrtext_tmp
);
318 mregex_geturltwo
= re
.escape("<img class=\"static\" src=\"http://cdn.thumbs.motherlessmedia.com/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" data-strip-src=\"http://cdn.thumbs.motherlessmedia.com/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" alt=\"")+"(.*)"+re
.escape("\" />");
319 mlesslinktwo
= re
.findall(mregex_geturltwo
, mrtext
);
320 mregex_getuserinfo
= re
.escape("<a class=\"caption left\" href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\">");
321 mlessuname
= re
.findall(mregex_getuserinfo
, mrtext
);
322 if(getlinks
[1]>len(mlesslinkone
) or getlinks
[1]==-1):
323 getlinks
[1] = len(mlesslinkone
);
324 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
325 tmpgetlinks0
= getlinks
[0];
326 tmpgetlinks1
= getlinks
[1];
327 getlinks
[0] = tmpgetlinks1
;
328 getlinks
[1] = tmpgetlinks0
;
333 returnval
= {'pages': lastpage
};
334 returnval
.update({'curpage': page
});
335 returnval
.update({'numoflinks': mlil
});
336 returnval
.update({'numofalllinks': len(mlesslinkone
)});
337 returnval
.update({'orginurl': httpurl
});
338 returnval
.update({'orginurltype': get_motherless_get_link_type(httpurl
)});
339 mlessrooturltype
= get_motherless_get_link_type(httpurl
);
340 returnval
.update({'urltype': mlessrooturltype
});
342 stripfilenameext
= os
.path
.basename(urlparse
.urljoin("http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][1], urlparse
.urlparse("http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][1]).path
));
343 stripfilename
, stripfileextension
= os
.path
.splitext(stripfilenameext
);
344 thumbfilenameext
= os
.path
.basename(urlparse
.urljoin("http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][0], urlparse
.urlparse("http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][0]).path
));
345 thumbfilename
, thumbfileextension
= os
.path
.splitext(thumbfilenameext
);
346 mlessurltype
= get_motherless_get_link_type("http://motherless.com/"+mlesslinkone
[mli
]);
347 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin("http://cdn.avatars.motherlessmedia.com/thumbs/"+mlessuname
[mli
]+"-avatar.jpg", urlparse
.urlparse("http://cdn.avatars.motherlessmedia.com/thumbs/"+mlessuname
[mli
]+"-avatar.jpg").path
));
348 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
349 returnval
.update({mli
: {'urltype': mlessurltype
, 'url': "http://motherless.com/"+mlesslinkone
[mli
], 'thumbnail': "http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][0], 'strip': "http://cdn.thumbs.motherlessmedia.com/"+mlesslinktwo
[mli
][1], 'title': mlesslinktwo
[mli
][2], 'thumbfullfilename': thumbfilenameext
, 'thumbfilename': thumbfilename
, 'thumbextension': thumbfileextension
, 'stripfullfilename': stripfilenameext
, 'stripfilename': stripfilename
, 'stripextension': stripfileextension
, 'username': mlessuname
[mli
], 'avatarurl': "http://cdn.avatars.motherlessmedia.com/thumbs/"+mlessuname
[mli
]+"-avatar.jpg", 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
} });
353 def get_motherless_random_links(httpheaders
, httpcookie
, linktype
, getlinks
=[0, 80]):
354 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
355 tmpgetlinks0
= getlinks
[0];
356 tmpgetlinks1
= getlinks
[1];
357 getlinks
[0] = tmpgetlinks1
;
358 getlinks
[1] = tmpgetlinks0
;
363 if(linktype
=="image"):
364 returnval
= {'pages': 1};
365 returnval
.update({'curpage': 1});
366 returnval
.update({'numoflinks': 80});
367 returnval
.update({'numofalllinks': mlil
});
368 returnval
.update({'orginurl': "http://motherless.com/random/image"});
369 returnval
.update({'orginurltype': "gallery"});
370 returnval
.update({'urltype': "gallery"});
372 get_links
= get_motherless_links("http://motherless.com/random/image", httpheaders
, httpcookie
);
373 returnval
.update({mli
: {'urltype': get_motherless_get_link_type("http://motherless.com/"+get_links
['filename']), 'url': "http://motherless.com/"+get_links
['filename'], 'thumbnail': get_links
['thumbnail'], 'strip': get_links
['thumbnailalt'], 'title': get_links
['title'], 'thumbfullfilename': get_links
['thumbfullfilename'], 'thumbfilename': get_links
['thumbfilename'], 'thumbextension': get_links
['thumbextension'], 'stripfullfilename': get_links
['thumbnailaltfullfilename'], 'stripfilename': get_links
['thumbnailaltextension'], 'stripextension': get_links
['thumbnailaltfilename'], 'username': get_links
['username'], 'avatarurl': get_links
['avatarurl'], 'avatarfullfilename': get_links
['avatarfullfilename'], 'avatarfilename': get_links
['avatarfilename'], 'avatarextension': get_links
['avatarextension']} });
375 if(linktype
=="video"):
376 returnval
= {'pages': 1};
377 returnval
.update({'curpage': 1});
378 returnval
.update({'numoflinks': 80});
379 returnval
.update({'numofalllinks': mlil
});
380 returnval
.update({'orginurl': "http://motherless.com/random/video"});
381 returnval
.update({'orginurltype': "gallery"});
382 returnval
.update({'urltype': "gallery"});
384 get_links
= get_motherless_links("http://motherless.com/random/video", httpheaders
, httpcookie
);
385 returnval
.update({mli
: {'urltype': get_motherless_get_link_type("http://motherless.com/"+get_links
['filename']), 'url': "http://motherless.com/"+get_links
['filename'], 'thumbnail': get_links
['thumbnail'], 'strip': get_links
['thumbnailalt'], 'title': get_links
['title'], 'thumbfullfilename': get_links
['thumbfullfilename'], 'thumbfilename': get_links
['thumbfilename'], 'thumbextension': get_links
['thumbextension'], 'stripfullfilename': get_links
['thumbnailaltfullfilename'], 'stripfilename': get_links
['thumbnailaltextension'], 'stripextension': get_links
['thumbnailaltfilename'], 'username': get_links
['username'], 'avatarurl': get_links
['avatarurl'], 'avatarfullfilename': get_links
['avatarfullfilename'], 'avatarfilename': get_links
['avatarfilename'], 'avatarextension': get_links
['avatarextension']} });
389 def get_motherless_boards_links(httpurl
, httpheaders
, httpcookie
, getlinks
=[0, -1]):
390 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
391 mrtext_tmp
= re
.sub(re
.escape("http://motherless.com"), "", mrtext
);
392 mrtext_tmp
= re
.sub(re
.escape("http://www.motherless.com"), "", mrtext_tmp
);
393 mrtext_tmp
= re
.sub(re
.escape("http://motherless.com"), "", mrtext_tmp
);
394 mrtext_tmp
= re
.sub(re
.escape("http://www.motherless.com"), "", mrtext_tmp
);
395 mregex_geturlone
= re
.escape("<a href=\"/")+"([\w\/]+)"+re
.escape("\" title=\"motherless link\">");
396 mlesslinkone
= re
.findall(mregex_geturlone
, mrtext_tmp
);
397 mregex_geturlname
= re
.escape("<a href=\"/boards/member/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" class=\"post-username special-member op-member\" title=\"op\" rel=\"")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\">");
398 mlessurlname
= re
.findall(mregex_geturlname
, mrtext
);
399 mlessavaturl
= "http://cdn.avatars.motherlessmedia.com/thumbs/"+mlessurlname
[0][0]+"-avatar.jpg";
400 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin(mlessavaturl
, urlparse
.urlparse(mlessavaturl
).path
));
401 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
402 if(getlinks
[1]>len(mlesslinkone
) or getlinks
[1]==-1):
403 getlinks
[1] = len(mlesslinkone
);
404 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
405 tmpgetlinks0
= getlinks
[0];
406 tmpgetlinks1
= getlinks
[1];
407 getlinks
[0] = tmpgetlinks1
;
408 getlinks
[1] = tmpgetlinks0
;
413 returnval
= {'numoflinks': mlil
};
414 returnval
.update({'numofalllinks': len(mlesslinkone
)});
415 returnval
.update({'orginurl': httpurl
});
416 returnval
.update({'orginurltype': get_motherless_get_link_type(httpurl
)});
417 mlessrooturltype
= get_motherless_get_link_type(httpurl
);
418 returnval
.update({'urltype': mlessrooturltype
});
419 returnval
.update({'username': mlessurlname
[0][0]});
420 returnval
.update({'avatarurl': mlessavaturl
});
421 returnval
.update({'avatarfullfilename': avatarfilenameext
});
422 returnval
.update({'avatarfilename': avatarfilename
});
423 returnval
.update({'avatarextension': avatarfileextension
});
425 mlessurltype
= get_motherless_get_link_type("http://motherless.com/"+mlesslinkone
[mli
]);
426 returnval
.update({mli
: {'urltype': mlessurltype
, 'url': "http://motherless.com/"+mlesslinkone
[mli
]} });
430 def get_motherless_search_members(httpurl
, httpheaders
, httpcookie
, page
=1, getlinks
=[0, -1]):
431 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
432 mregex_getpagenum
= re
.escape("page=")+"([0-9]+)"+re
.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re
.escape("\">")+"([0-9]+)"+re
.escape("</a>");
433 mlesspagenum
= re
.findall(mregex_getpagenum
, mrtext
);
435 lastpage
= mlesspagenum
[-1][0];
440 httpurl
= add_url_param(httpurl
, page
=str(page
));
441 mrtext
= download_from_url(httpurl
, httpheaders
, httpcookie
);
442 mregex_getuname
= re
.escape("<tr rel=\"")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\"");
443 mlessuname
= re
.findall(mregex_getuname
, mrtext
);
444 mregex_geturlname
= re
.escape("<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" target=\"_blank\">\n <img");
445 mlessurlname
= re
.findall(mregex_geturlname
, mrtext
);
446 mregex_getavatar
= re
.escape("<img\n src=\"")+"(.*)"+re
.escape("\"\n class=\"avatar avatar-small\"");
447 mlessavatar
= re
.findall(mregex_getavatar
, mrtext
);
448 if(getlinks
[1]>len(mlesslinkone
) or getlinks
[1]==-1):
449 getlinks
[1] = len(mlesslinkone
);
450 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
451 tmpgetlinks0
= getlinks
[0];
452 tmpgetlinks1
= getlinks
[1];
453 getlinks
[0] = tmpgetlinks1
;
454 getlinks
[1] = tmpgetlinks0
;
459 returnval
= {'numoflinks': mlil
};
460 returnval
.update({'numofalllinks': len(mlessuname
)});
461 returnval
.update({'pages': lastpage
});
462 returnval
.update({'curpage': page
});
463 returnval
.update({'orginurl': httpurl
});
464 returnval
.update({'orginurltype': get_motherless_get_link_type(httpurl
)});
465 mlessrooturltype
= get_motherless_get_link_type(httpurl
);
466 returnval
.update({'urltype': mlessrooturltype
});
468 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin(mlessavatar
[mli
], urlparse
.urlparse(mlessavatar
[mli
]).path
));
469 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
470 mlessurltype
= get_motherless_get_link_type("http://motherless.com/"+mlessurlname
[mli
]);
471 returnval
.update({mli
: {'urltype': mlessurltype
, 'url': "http://motherless.com/"+mlessurlname
[mli
], 'username': mlessuname
[mli
], 'avatarurl': mlessavatar
[mli
], 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
} });
475 def get_motherless_girls(httpheaders
, httpcookie
, getlinks
=[0, -1]):
476 mrtext
= download_from_url("http://motherless.com/girls", httpheaders
, httpcookie
);
477 mregex_getuname
= re
.escape("<a href=\"")+"(.*)"+re
.escape("\" rev=\"")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" rel=\"")+"(.*)"+re
.escape("\">");
478 mlessuname
= re
.findall(mregex_getuname
, mrtext
);
479 mregex_geturlname
= re
.escape("\n\t\t\t\t\t\t<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\" target=\"_blank\">");
480 mlessurlname
= re
.findall(mregex_geturlname
, mrtext
);
481 if(getlinks
[1]>len(mlesslinkone
) or getlinks
[1]==-1):
482 getlinks
[1] = len(mlesslinkone
);
483 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
484 tmpgetlinks0
= getlinks
[0];
485 tmpgetlinks1
= getlinks
[1];
486 getlinks
[0] = tmpgetlinks1
;
487 getlinks
[1] = tmpgetlinks0
;
492 returnval
= {'numoflinks': mlil
};
493 returnval
.update({'numofalllinks': len(mlessuname
)});
494 returnval
.update({'orginurl': "http://motherless.com/girls"});
495 returnval
.update({'orginurltype': get_motherless_get_link_type("http://motherless.com/girls")});
496 mlessrooturltype
= get_motherless_get_link_type("http://motherless.com/girls");
497 returnval
.update({'urltype': mlessrooturltype
});
499 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin(mlessuname
[mli
][0], urlparse
.urlparse(mlessuname
[mli
][0]).path
));
500 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
501 mlessurltype
= get_motherless_get_link_type("http://motherless.com/"+mlessuname
[mli
][1]);
502 returnval
.update({mli
: {'urltype': mlessurltype
, 'url': "http://motherless.com/"+mlessuname
[mli
][1], 'username': mlessuname
[mli
][1], 'avatarurl': mlessuname
[mli
][0], 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
} });
506 def get_motherless_team(httpheaders
, httpcookie
, getlinks
=[0, -1]):
507 mrtext
= download_from_url("http://motherless.com/about", httpheaders
, httpcookie
);
508 mregex_getuname
= re
.escape("<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re
.escape("\"");
509 mlessuname
= re
.findall(mregex_getuname
, mrtext
);
510 mlessuname_odd
= mlessuname
[1::2];
511 mlessuname_even
= mlessuname
[::2];
512 mregex_getavatar
= re
.escape("<img\n src=\"")+"(.*)"+re
.escape("\"\n class=\"avatar avatar-")+"(full|medium)"+re
.escape("\"");
513 mlessavatar
= re
.findall(mregex_getavatar
, mrtext
);
514 if(getlinks
[1]>len(mlessuname_odd
) or getlinks
[1]==-1):
515 getlinks
[1] = len(mlessuname_odd
);
516 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
517 tmpgetlinks0
= getlinks
[0];
518 tmpgetlinks1
= getlinks
[1];
519 getlinks
[0] = tmpgetlinks1
;
520 getlinks
[1] = tmpgetlinks0
;
525 returnval
= {'numoflinks': mlil
};
526 returnval
.update({'numofalllinks': len(mlessuname
)});
527 returnval
.update({'orginurl': "http://motherless.com/girls"});
528 returnval
.update({'orginurltype': get_motherless_get_link_type("http://motherless.com/girls")});
529 mlessrooturltype
= get_motherless_get_link_type("http://motherless.com/girls");
530 returnval
.update({'urltype': mlessrooturltype
});
532 avatarfilenameext
= os
.path
.basename(urlparse
.urljoin(mlessavatar
[mli
][0], urlparse
.urlparse(mlessavatar
[mli
][0]).path
));
533 avatarfilename
, avatarfileextension
= os
.path
.splitext(avatarfilenameext
);
534 mlessurltype
= get_motherless_get_link_type("http://motherless.com/"+mlessuname_odd
[mli
]);
535 returnval
.update({mli
: {'urltype': mlessurltype
, 'url': "http://motherless.com/"+mlessuname_odd
[mli
], 'username': mlessuname_odd
[mli
], 'avatarurl': mlessavatar
[mli
][0], 'avatarfullfilename': avatarfilenameext
, 'avatarfilename': avatarfilename
, 'avatarextension': avatarfileextension
} });
539 def get_motherless_top_referrers(httpheaders
, httpcookie
, getlinks
=[0, -1]):
540 mrtext
= download_from_url("http://motherless.com/referers", httpheaders
, httpcookie
);
541 mregex_geturlname
= "([0-9]+)"+re
.escape(". <a href=\"")+"(.*)"+re
.escape(" class=\"pop\" target=\"_blank\" rel=\"nofollow\">\n ")+"(.*)"+re
.escape(" </a>");
542 mlessurlname
= re
.findall(mregex_geturlname
, mrtext
);
543 if(getlinks
[1]>len(mlessurlname
) or getlinks
[1]==-1):
544 getlinks
[1] = len(mlessurlname
);
545 if(getlinks
[0]>getlinks
[1] and not getlinks
[1]==-1):
546 tmpgetlinks0
= getlinks
[0];
547 tmpgetlinks1
= getlinks
[1];
548 getlinks
[0] = tmpgetlinks1
;
549 getlinks
[1] = tmpgetlinks0
;
554 returnval
= {'numoflinks': mlil
};
555 returnval
.update({'numofalllinks': len(mlessurlname
)});
556 returnval
.update({'orginurl': "http://motherless.com/referers"});
557 returnval
.update({'orginurltype': get_motherless_get_link_type("http://motherless.com/referers")});
558 mlessrooturltype
= get_motherless_get_link_type("http://motherless.com/referers");
559 returnval
.update({'urltype': mlessrooturltype
});
561 returnval
.update({mli
: {'urltype': "referer-links", 'url': mlessurlname
[mli
][1], 'title': mlessurlname
[mli
][2]} });
565 def get_motherless_top_referers(httpheaders
, httpcookie
, getlinks
=[0, -1]):
566 return get_motherless_top_referrers(httpheaders
, httpcookie
, getlinks
);
568 def get_motherless_sample_links(httpheaders
, httpcookie
, numoflinks
=10, urltype
="video"):
569 if(urltype
=="video"):
570 returnval
= {'numoflinks': numoflinks
, 'orginurl': "http://motherless.com/videos", 'orginurltype': get_motherless_get_link_type("http://motherless.com/videos"), 'videos': {'recent': get_motherless_galleries_links("http://motherless.com/videos/recent", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/videos/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/videos/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/videos/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'popular': get_motherless_galleries_links("http://motherless.com/videos/popular", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'live': get_motherless_galleries_links("http://motherless.com/live/videos", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'random': get_motherless_random_links(httpheaders
, httpcookie
, "video", [0, numoflinks
]) } };
571 if(urltype
=="image"):
572 returnval
= {'numoflinks': numoflinks
, 'orginurl': "http://motherless.com/images", 'orginurltype': get_motherless_get_link_type("http://motherless.com/images"), 'images': {'recent': get_motherless_galleries_links("http://motherless.com/images/recent", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/images/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/images/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/images/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'popular': get_motherless_galleries_links("http://motherless.com/images/popular", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'live': get_motherless_galleries_links("http://motherless.com/live/images", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'random': get_motherless_random_links(httpheaders
, httpcookie
, "image", [0, numoflinks
]) } };
573 if(urltype
=="gallery"):
574 returnval
= {'numoflinks': numoflinks
, 'orginurl': "http://motherless.com/galleries", 'orginurltype': get_motherless_get_link_type("http://motherless.com/galleries"), 'galleries': {'updated': get_motherless_galleries_links("http://motherless.com/galleries/updated", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'created': get_motherless_galleries_links("http://motherless.com/galleries/created", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/galleries/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/galleries/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/galleries/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]) } };
576 returnval
= {'numoflinks': numoflinks
, 'orginurl': "http://motherless.com/", 'orginurltype': get_motherless_get_link_type("http://motherless.com/"), 'videos': {'recent': get_motherless_galleries_links("http://motherless.com/videos/recent", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/videos/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/videos/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/videos/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'popular': get_motherless_galleries_links("http://motherless.com/videos/popular", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'live': get_motherless_galleries_links("http://motherless.com/live/videos", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'random': get_motherless_random_links(httpheaders
, httpcookie
, "video", [0, numoflinks
]) }, 'images': {'recent': get_motherless_galleries_links("http://motherless.com/images/recent", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/images/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/images/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/images/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'popular': get_motherless_galleries_links("http://motherless.com/images/popular", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'live': get_motherless_galleries_links("http://motherless.com/live/images", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'random': get_motherless_random_links(httpheaders
, httpcookie
, "image", [0, numoflinks
]) }, 'galleries': {'updated': get_motherless_galleries_links("http://motherless.com/galleries/updated", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'created': get_motherless_galleries_links("http://motherless.com/galleries/created", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'viewed': get_motherless_galleries_links("http://motherless.com/galleries/viewed", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'favorited': get_motherless_galleries_links("http://motherless.com/galleries/favorited", httpheaders
, httpcookie
, 1, [0, numoflinks
]), 'commented': get_motherless_galleries_links("http://motherless.com/galleries/commented", httpheaders
, httpcookie
, 1, [0, numoflinks
]) } };
579 def get_motherless_get_link_by_type(httpurl
, httpheaders
, httpcookie
, page
=1, getlinks
=[0, -1]):
581 if(get_motherless_get_link_type(httpurl
)=="file"):
582 returnval
= get_motherless_links(httpurl
, httpheaders
, httpcookie
);
583 if(get_motherless_get_link_type(httpurl
)=="gallery"):
584 returnval
= get_motherless_galleries_links(httpurl
, httpheaders
, httpcookie
, page
);
585 if(get_motherless_get_link_type(httpurl
)=="sample-videos"):
586 returnval
= get_motherless_sample_links(httpheaders
, httpcookie
, 10, "video");
587 if(get_motherless_get_link_type(httpurl
)=="sample-images"):
588 returnval
= get_motherless_sample_links(httpheaders
, httpcookie
, 10, "image");
589 if(get_motherless_get_link_type(httpurl
)=="sample-galleries"):
590 returnval
= get_motherless_sample_links(httpheaders
, httpcookie
, 10, "gallery");
591 if(get_motherless_get_link_type(httpurl
)=="sample"):
592 returnval
= get_motherless_sample_links(httpheaders
, httpcookie
, 10, "all");
593 if(get_motherless_get_link_type(httpurl
)=="board"):
594 returnval
= get_motherless_boards_links(httpurl
, httpheaders
, httpcookie
);
595 if(get_motherless_get_link_type(httpurl
)=="member"):
596 returnval
= get_motherless_search_members(httpurl
, httpheaders
, httpcookie
, page
);
597 if(get_motherless_get_link_type(httpurl
)=="girls"):
598 returnval
= get_motherless_girls(httpheaders
, httpcookie
);
599 if(get_motherless_get_link_type(httpurl
)=="download"):
603 def view_motherless_links(httpurl
, httpheaders
, httpcookie
, viewerpro
, prearg
=[], proarg
=[]):
604 commandlist
= [viewerpro
] + prearg
;
605 commandlist
= commandlist
+ [get_motherless_links(httpurl
, httpheaders
, httpcookie
)['url']];
606 commandlist
= commandlist
+ proarg
;
607 mpvplaylistp
= subprocess
.Popen(commandlist
, stdout
=subprocess
.PIPE
, stderr
=subprocess
.PIPE
);
608 mpvplayout
, mpvplayerr
= mpvplaylistp
.communicate();
611 def download_motherless_links(httpurl
, httpheaders
, httpcookie
, sleep
=-1, outfile
="-", outpath
=os
.getcwd(), usetitlename
=False):
612 global geturls_download_sleep
;
614 sleep
= geturls_download_sleep
;
615 mlessurl
= get_motherless_links(httpurl
, httpheaders
, httpcookie
);
616 outputname
= mlessurl
['fullfilename'];
617 outpath
= outpath
.rstrip(os
.path
.sep
);
618 if(usetitlename
==True):
619 outputname
= mlessurl
['title'];
620 if(usetitlename
=="-" and outfile
=="-"):
622 if(usetitlename
=="-" and not outfile
=="-"):
623 outputname
= outfile
;
624 returnval
= download_from_url_to_file(mlessurl
['url'], httpheaders
, httpcookie
, outputname
, outpath
, sleep
);
627 def download_motherless_links_by_type(httpurl
, httpheaders
, httpcookie
, sleep
=-1, outfile
="-", outpath
=os
.getcwd(), usetitlename
=False, page
=1, getlinks
=[0, -1]):
628 global geturls_download_sleep
;
630 sleep
= geturls_download_sleep
;
631 mlessurl
= get_motherless_get_link_by_type(httpurl
, httpheaders
, httpcookie
, page
);
632 if(mlessurl
['urltype']=="download"):
633 outputname
= mlessurl
['fullfilename'];
634 outpathname
= outpath
.rstrip(os
.path
.sep
);
635 if(usetitlename
==True):
636 outputname
= mlessurl
['title'];
637 if(usetitlename
=="-" and outfile
[mli
]=="-"):
639 if(usetitlename
=="-" and not outfile
[mli
]=="-"):
640 outputname
= outfile
;
641 returnval
= download_from_url_to_file(mlessurl
['url'], httpheaders
, httpcookie
, outputname
, outpathname
, sleep
);
642 if(not mlessurl
['urltype']=="download"):
643 returnval
= mlessurl
;
646 def download_motherless_galleries_links(httpurl
, httpheaders
, httpcookie
, sleep
=-1, outfile
="-", outpath
=os
.getcwd(), usetitlename
=False, page
=1, getlinks
=[0, -1]):
647 global geturls_download_sleep
;
649 sleep
= geturls_download_sleep
;
650 mlessgalleries
= get_motherless_galleries_links(httpurl
, httpheaders
, httpcookie
, page
, getlinks
);
652 mlil
= mlessgalleries
['numoflinks'];
653 returnval
= {'pages': mlessgalleries
['pages']};
654 returnval
.update({'numoflists': mlessgalleries
['numoflinks']});
655 returnval
.update({'curpage': mlessgalleries
['curpage']});
656 returnval
.update({'numoflinks': mlessgalleries
['numoflinks']});
657 returnval
.update({'numofalllinks': mlessgalleries
['numofalllinks']});
658 returnval
.update({'orginurl': httpurl
});
659 returnval
.update({'orginurltype': get_motherless_get_link_type(httpurl
)});
661 mlesslink
= get_motherless_links(mlessgalleries
[mli
]['url'], httpheaders
, httpcookie
);
662 outputname
= mlesslink
['fullfilename'];
663 outpath
= outpath
.rstrip(os
.path
.sep
);
664 if(usetitlename
==True):
665 outputname
= mlesslink
['title'];
666 if(usetitlename
=="-" and outfile
=="-"):
668 if(usetitlename
=="-" and not outfile
=="-"):
669 outputname
= outfile
;
670 returnval
.update({mli
: {'download': download_from_url_to_file(mlesslink
['url'], httpheaders
, httpcookie
, outputname
, outpath
, sleep
), 'linkinfo': mlesslink
} });
674 def download_get_motherless_boards_links(httpurl
, httpheaders
, httpcookie
, sleep
=-1, outfile
="-", outpath
=os
.getcwd(), usetitlename
=False, getlinks
=[0, -1]):
675 global geturls_download_sleep
;
677 sleep
= geturls_download_sleep
;
678 mlessgalleries
= get_motherless_boards_links(httpurl
, httpheaders
, httpcookie
, getlinks
);
680 mlil
= mlessgalleries
['numoflinks'];
681 returnval
= {'numoflists': mlessgalleries
['numoflinks']};
682 returnval
.update({'numofalllinks': mlessgalleries
['numofalllinks']});
683 returnval
.update({'orginurl': httpurl
});
684 returnval
.update({'orginurltype': get_motherless_get_link_type(httpurl
)});
686 mlesslink
= get_motherless_links(mlessgalleries
[mli
]['url'], httpheaders
, httpcookie
);
687 outputname
= mlesslink
['fullfilename'];
688 outpath
= outpath
.rstrip(os
.path
.sep
);
689 if(usetitlename
==True):
690 outputname
= mlesslink
['title'];
691 if(usetitlename
=="-" and outfile
=="-"):
693 if(usetitlename
=="-" and not outfile
=="-"):
694 outputname
= outfile
;
695 returnval
.update({mli
: {'download': download_from_url_to_file(mlesslink
['url'], httpheaders
, httpcookie
, outputname
, outpath
, sleep
), 'linkinfo': mlesslink
} });