Another small update.
[Python-Scripts.git] / MiniScripts / pymotherless.py
blob9838371f89d153f3069a8e06f44db83521775ce2
1 #!/usr/bin/env python
3 '''
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/19/2016 Ver. 0.2.8 RC 1 - Author: cooldude2k $
17 '''
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"):
22 try:
23 from cStringIO import StringIO;
24 except ImportError:
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, 2, 8, "RC 1");
36 __version_date__ = "2016.01.19";
37 if(__version_info__[3]!=None):
38 __version__ = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str(__version_info__[2])+" "+str(__version_info__[3]);
39 if(__version_info__[3]==None):
40 __version__ = str(__version_info__[0])+"."+str(__version_info__[1])+"."+str(__version_info__[2]);
42 geturls_cj = cookielib.CookieJar();
43 geturls_ua_firefox_windows7 = "Mozilla/5.0 (Windows NT 6.1; rv:43.0) Gecko/20100101 Firefox/43.0";
44 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";
45 geturls_ua_internet_explorer_windows7 = "Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko";
46 geturls_ua = geturls_ua_firefox_windows7;
47 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")];
48 geturls_download_sleep = 0;
50 def add_url_param(url, **params):
51 n=3;
52 parts = list(urlparse.urlsplit(url));
53 d = dict(cgi.parse_qsl(parts[n])); # use cgi.parse_qs for list values
54 d.update(params);
55 parts[n]=urllib.urlencode(d);
56 return urlparse.urlunsplit(parts);
58 os.environ["PATH"] = os.environ["PATH"] + os.pathsep + os.path.dirname(os.path.realpath(__file__)) + os.pathsep + os.getcwd();
59 def which_exec(execfile):
60 for path in os.environ["PATH"].split(":"):
61 if os.path.exists(path + "/" + execfile):
62 return path + "/" + execfile;
64 def listize(varlist):
65 il = 0;
66 ix = len(varlist);
67 ilx = 1;
68 newlistreg = {};
69 newlistrev = {};
70 newlistfull = {};
71 while(il < ix):
72 newlistreg.update({ilx: varlist[il]});
73 newlistrev.update({varlist[il]: ilx});
74 ilx = ilx + 1;
75 il = il + 1;
76 newlistfull = {1: newlistreg, 2: newlistrev, 'reg': newlistreg, 'rev': newlistrev};
77 return newlistfull;
79 def twolistize(varlist):
80 il = 0;
81 ix = len(varlist);
82 ilx = 1;
83 newlistnamereg = {};
84 newlistnamerev = {};
85 newlistdescreg = {};
86 newlistdescrev = {};
87 newlistfull = {};
88 while(il < ix):
89 newlistnamereg.update({ilx: varlist[il][0].strip()});
90 newlistnamerev.update({varlist[il][0].strip(): ilx});
91 newlistdescreg.update({ilx: varlist[il][1].strip()});
92 newlistdescrev.update({varlist[il][1].strip(): ilx});
93 ilx = ilx + 1;
94 il = il + 1;
95 newlistnametmp = {1: newlistnamereg, 2: newlistnamerev, 'reg': newlistnamereg, 'rev': newlistnamerev};
96 newlistdesctmp = {1: newlistdescreg, 2: newlistdescrev, 'reg': newlistdescreg, 'rev': newlistdescrev};
97 newlistfull = {1: newlistnametmp, 2: newlistdesctmp, 'name': newlistnametmp, 'desc': newlistdesctmp}
98 return newlistfull;
100 def arglistize(proexec, *varlist):
101 il = 0;
102 ix = len(varlist);
103 ilx = 1;
104 newarglist = [proexec];
105 while(il < ix):
106 if varlist[il][0] is not None:
107 newarglist.append(varlist[il][0]);
108 if varlist[il][1] is not None:
109 newarglist.append(varlist[il][1]);
110 il = il + 1;
111 return newarglist;
113 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"}):
114 returnval = [];
115 for headkey, headvalue in headers.iteritems():
116 returnval.append((headkey, headvalue));
117 return returnval;
119 def download_from_url(httpurl, httpheaders, httpcookie, sleep=-1):
120 global geturls_download_sleep;
121 if(sleep<0):
122 sleep = geturls_download_sleep;
123 geturls_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(httpcookie));
124 geturls_opener.addheaders = httpheaders;
125 time.sleep(sleep);
126 geturls_text = geturls_opener.open(httpurl);
127 if(geturls_text.info().get("Content-Encoding")=="gzip" or geturls_text.info().get("Content-Encoding")=="deflate"):
128 if(sys.version[0]=="2"):
129 strbuf = StringIO(geturls_text.read());
130 if(sys.version[0]=="3"):
131 strbuf = BytesIO(geturls_text.read());
132 gzstrbuf = gzip.GzipFile(fileobj=strbuf);
133 if(sys.version[0]=="2"):
134 returnval = gzstrbuf.read()[:];
135 if(sys.version[0]=="3"):
136 returnval = gzstrbuf.read()[:].decode('ascii', 'replace');
137 if(geturls_text.info().get("Content-Encoding")!="gzip" and geturls_text.info().get("Content-Encoding")!="deflate"):
138 returnval = geturls_text.read()[:];
139 return returnval;
141 def download_from_url_file(httpurl, httpheaders, httpcookie, sleep=-1):
142 global geturls_download_sleep;
143 if(sleep<0):
144 sleep = geturls_download_sleep;
145 geturls_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(httpcookie));
146 geturls_opener.addheaders = httpheaders;
147 time.sleep(sleep);
148 geturls_text = geturls_opener.open(httpurl);
149 if(geturls_text.info().get("Content-Encoding")=="gzip" or geturls_text.info().get("Content-Encoding")=="deflate"):
150 if(sys.version[0]=="2"):
151 strbuf = StringIO(geturls_text.read());
152 if(sys.version[0]=="3"):
153 strbuf = BytesIO(geturls_text.read());
154 gzstrbuf = gzip.GzipFile(fileobj=strbuf);
155 returnval = gzstrbuf.read()[:];
156 if(geturls_text.info().get("Content-Encoding")!="gzip" and geturls_text.info().get("Content-Encoding")!="deflate"):
157 returnval = geturls_text.read()[:];
158 return returnval;
160 def download_from_url_to_file(httpurl, httpheaders, httpcookie, outfile="-", outpath=os.getcwd(), sleep=-1):
161 global geturls_download_sleep;
162 if(sleep<0):
163 sleep = geturls_download_sleep;
164 if(not outfile=="-"):
165 outpath = outpath.rstrip(os.path.sep);
166 filepath = os.path.realpath(outpath+os.path.sep+outfile);
167 if(not os.path.exists(outpath)):
168 os.makedirs(outpath);
169 if(os.path.exists(outpath) and os.path.isfile(outpath)):
170 return False;
171 if(os.path.exists(filepath) and os.path.isdir(filepath)):
172 return False;
173 with open(filepath, 'wb+') as f:
174 f.write(download_from_url_file(httpurl, httpheaders, httpcookie, sleep));
175 f.closed;
176 returnval = True;
177 if(outfile=="-" and sys.version[0]=="2"):
178 f = StringIO();
179 f.write(download_from_url_file(httpurl, httpheaders, httpcookie, sleep));
180 returnval = f.getvalue();
181 f.closed;
182 if(outfile=="-" and sys.version[0]=="3"):
183 f = BytesIO();
184 f.write(download_from_url_file(httpurl, httpheaders, httpcookie, sleep));
185 returnval = f.getvalue();
186 f.closed;
187 return returnval;
189 def get_motherless_get_number_pages(httpurl, httpheaders, httpcookie):
190 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
191 mregex_getpagenum = re.escape("page=")+"([0-9]+)"+re.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+re.escape("</a>");
192 mlesspagenum = re.findall(mregex_getpagenum, mrtext);
193 try:
194 returnval = mlesspagenum[-1][0];
195 except:
196 returnval = 1;
197 return returnval;
199 def get_motherless_get_link_type(httpurl):
200 mlessvidqstr = urlparse.parse_qs(urlparse.urlparse(httpurl).query);
201 mlessvidid_parts = urlparse.urlparse(httpurl);
202 mlessvidid = mlessvidid_parts.path.split("/");
203 returnval = False;
204 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")):
205 returnval = "gallery";
206 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")):
207 returnval = "gallery";
208 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")):
209 returnval = "gallery";
210 if(mlessvidid[1]=="videos" and len(mlessvidid)==2):
211 returnval = "sample-videos";
212 if(mlessvidid[1]=="images" and len(mlessvidid)==2):
213 returnval = "sample-images";
214 if(mlessvidid[1]=="galleries" and len(mlessvidid)==2):
215 returnval = "sample-galleries";
216 if(mlessvidid[1]=="" and len(mlessvidid)==2):
217 returnval = "sample";
218 if(mlessvidid[1]=="live" and len(mlessvidid)==3 and (mlessvidid[2]=="videos" or mlessvidid[2]=="images")):
219 returnval = "gallery";
220 if(mlessvidid[1]=="u" and len(mlessvidid)==3):
221 returnval = "gallery";
222 if(mlessvidid[1]=="f" and len(mlessvidid)==4 and (mlessvidid[2]=="videos" or mlessvidid[2]=="images" or mlessvidid[2]=="galleries")):
223 returnval = "gallery";
224 if(mlessvidid[1]=="galleries" and len(mlessvidid)==4 and mlessvidid[2]=="member"):
225 returnval = "gallery";
226 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")):
227 returnval = "gallery";
228 if(mlessvidid[1]=="gv" and len(mlessvidid)==3):
229 returnval = "gallery";
230 if(mlessvidid[1]=="gi" and len(mlessvidid)==3):
231 returnval = "gallery";
232 if(mlessvidid[1]=="term" and len(mlessvidid)==3 and (mlessvidid[2]=="videos" or mlessvidid[2]=="images" or mlessvidid[2]=="galleries")):
233 returnval = "gallery";
234 if(mlessvidid[1]=="g" and len(mlessvidid)==4):
235 returnval = "file";
236 if(mlessvidid[1]=="random" and len(mlessvidid)==3 and (mlessvidid[2]=="video" or mlessvidid[2]=="image")):
237 returnval = "file";
238 if(re.match("^V", mlessvidid[1]) and len(mlessvidid)==2):
239 returnval = "board";
240 if(mlessvidid[1]=="members" and len(mlessvidid)==2):
241 returnval = "member";
242 if(mlessvidid[1]=="members" and mlessvidid[2]=="search" and len(mlessvidid)==3):
243 returnval = "member";
244 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")):
245 returnval = "member";
246 if(mlessvidid[1]=="girls" and len(mlessvidid)==2):
247 returnval = "girls";
248 if(mlessvidid_parts.netloc=="cdn.images.motherlessmedia.com" or mlessvidid_parts.netloc=="cdn.videos.motherlessmedia.com" or mlessvidid_parts.netloc=="cdn.thumbs.motherlessmedia.com"):
249 returnval = "download";
250 if(returnval==False and len(mlessvidid)==2):
251 returnval = "file";
252 return returnval;
254 def get_motherless_links(httpurl, httpheaders, httpcookie):
255 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
256 mregex_gettitle = re.escape("<title>")+"(.*)"+re.escape(" - MOTHERLESS.COM</title>");
257 mlesstitle = re.findall(mregex_gettitle, mrtext);
258 mregex_geturlone = re.escape("__fileurl = 'http://cdn.")+"(images|videos)"+re.escape(".motherlessmedia.com/")+"(images|videos)"+re.escape("/")+"([\w\/\?\&\=\.\-]+)"+re.escape("';");
259 mlesslinkone = re.findall(mregex_geturlone, mrtext);
260 mregex_geturltwo = re.escape("<meta property=\"og:image\" content=\"http://cdn.")+"(images|thumbs)"+re.escape(".motherlessmedia.com/")+"(images|thumbs)"+re.escape("/")+"([\w\/\?\&\=\.\-]+)"+re.escape("\">");
261 mlesslinktwo = re.findall(mregex_geturltwo, mrtext);
262 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));
263 filename, fileextension = os.path.splitext(filenameext);
264 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));
265 thumbfilename, thumbfileextension = os.path.splitext(thumbfilenameext);
266 mregex_getuname = re.escape("<tr rel=\"")+"([\w\/\?\&\=\.\-]+)"+re.escape("\"");
267 mlessuname = re.findall(mregex_getuname, mrtext);
268 mlessuname = mlessuname[0];
269 mregex_geturlname = re.escape("<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re.escape("\" target=\"_blank\">\n <img");
270 mlessurlname = re.findall(mregex_geturlname, mrtext);
271 mlessurlname = mlessurlname[0];
272 mregex_getavatar = re.escape("<img\n src=\"")+"(.*)"+re.escape("\"\n class=\"avatar avatar-small\"");
273 mlessavatar = re.findall(mregex_getavatar, mrtext);
274 mlessavatar = mlessavatar[0];
275 avatarfilenameext = os.path.basename(urlparse.urljoin(mlessavatar, urlparse.urlparse(mlessavatar).path));
276 avatarfilename, avatarfileextension = os.path.splitext(avatarfilenameext);
277 if(mlesslinkone[0][1]=="images"):
278 thumbnailaltpart = thumbfilename+"-zoom"+thumbfileextension;
279 thumbnailalt = "http://cdn.thumbs.motherlessmedia.com/thumbs/"+thumbnailaltpart;
280 thumbnailaltfilenameext = os.path.basename(urlparse.urljoin(thumbnailalt, urlparse.urlparse(thumbnailalt).path));
281 thumbnailaltfilename, thumbnailaltfileextension = os.path.splitext(thumbnailaltfilenameext);
282 if(mlesslinkone[0][1]=="videos"):
283 thumbnailaltpart = +thumbfilename+"-small"+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 returnval = False;
288 mlessurltype = get_motherless_get_link_type("http://cdn."+mlesslinkone[0][0]+".motherlessmedia.com/"+mlesslinkone[0][1]+"/"+mlesslinkone[0][2]);
289 if(mlesslinkone[0][1]=="images"):
290 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};
291 if(mlesslinkone[0][1]=="videos"):
292 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};
293 return returnval;
295 def get_motherless_galleries_links(httpurl, httpheaders, httpcookie, page=1, getlinks=[0, -1]):
296 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
297 mregex_getpagenum = re.escape("page=")+"([0-9]+)"+re.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+re.escape("</a>");
298 mlesspagenum = re.findall(mregex_getpagenum, mrtext);
299 try:
300 lastpage = mlesspagenum[-1][0];
301 except:
302 lastpage = 1;
303 if(page>lastpage):
304 page = lastpage;
305 httpurl = add_url_param(httpurl, page=str(page));
306 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
307 mregex_geturlone = re.escape("<a href=\"/")+"([\w\/]+)"+re.escape("\" class=\"img-container\" target=\"_self\">");
308 mrtext_tmp = re.sub(re.escape("http://motherless.com"), "", mrtext);
309 mrtext_tmp = re.sub(re.escape("http://www.motherless.com"), "", mrtext_tmp);
310 mrtext_tmp = re.sub(re.escape("http://motherless.com"), "", mrtext_tmp);
311 mrtext_tmp = re.sub(re.escape("http://www.motherless.com"), "", mrtext_tmp);
312 mlesslinkone = re.findall(mregex_geturlone, mrtext_tmp);
313 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("\" />");
314 mlesslinktwo = re.findall(mregex_geturltwo, mrtext);
315 mregex_getuserinfo = re.escape("<a class=\"caption left\" href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re.escape("\">");
316 mlessuname = re.findall(mregex_getuserinfo, mrtext);
317 if(getlinks[1]>len(mlesslinkone) or getlinks[1]==-1):
318 getlinks[1] = len(mlesslinkone);
319 if(getlinks[0]>getlinks[1] and not getlinks[1]==-1):
320 tmpgetlinks0 = getlinks[0];
321 tmpgetlinks1 = getlinks[1];
322 getlinks[0] = tmpgetlinks1;
323 getlinks[1] = tmpgetlinks0;
324 if(getlinks[0]<0):
325 getlinks[0] = 0;
326 mli = getlinks[0];
327 mlil = getlinks[1];
328 returnval = {'pages': lastpage};
329 returnval.update({'curpage': page});
330 returnval.update({'numoflinks': mlil});
331 returnval.update({'numofalllinks': len(mlesslinkone)});
332 returnval.update({'orginurl': httpurl});
333 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
334 mlessrooturltype = get_motherless_get_link_type(httpurl);
335 returnval.update({'urltype': mlessrooturltype});
336 while(mli<mlil):
337 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));
338 stripfilename, stripfileextension = os.path.splitext(stripfilenameext);
339 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));
340 thumbfilename, thumbfileextension = os.path.splitext(thumbfilenameext);
341 mlessurltype = get_motherless_get_link_type("http://motherless.com/"+mlesslinkone[mli]);
342 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]} });
343 mli = mli + 1;
344 return returnval;
346 def get_motherless_random_links(httpheaders, httpcookie, linktype, getlinks=[0, 80]):
347 if(getlinks[0]>getlinks[1] and not getlinks[1]==-1):
348 tmpgetlinks0 = getlinks[0];
349 tmpgetlinks1 = getlinks[1];
350 getlinks[0] = tmpgetlinks1;
351 getlinks[1] = tmpgetlinks0;
352 if(getlinks[0]<0):
353 getlinks[0] = 0;
354 mli = getlinks[0];
355 mlil = getlinks[1];
356 if(linktype=="image"):
357 returnval = {'pages': 1};
358 returnval.update({'curpage': 1});
359 returnval.update({'numoflinks': 80});
360 returnval.update({'numofalllinks': mlil});
361 returnval.update({'orginurl': "http://motherless.com/random/image"});
362 returnval.update({'orginurltype': "gallery"});
363 returnval.update({'urltype': "gallery"});
364 while(mli<mlil):
365 get_links = get_motherless_links("http://motherless.com/random/image", httpheaders, httpcookie);
366 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']} });
367 mli = mli + 1;
368 if(linktype=="video"):
369 returnval = {'pages': 1};
370 returnval.update({'curpage': 1});
371 returnval.update({'numoflinks': 80});
372 returnval.update({'numofalllinks': mlil});
373 returnval.update({'orginurl': "http://motherless.com/random/video"});
374 returnval.update({'orginurltype': "gallery"});
375 returnval.update({'urltype': "gallery"});
376 while(mli<mlil):
377 get_links = get_motherless_links("http://motherless.com/random/video", httpheaders, httpcookie);
378 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']} });
379 mli = mli + 1;
380 return returnval;
382 def get_motherless_boards_links(httpurl, httpheaders, httpcookie, getlinks=[0, -1]):
383 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
384 mregex_geturlone = re.escape("<a href=\"/")+"([\w\/]+)"+re.escape("\" title=\"motherless link\">");
385 mrtext_tmp = re.sub(re.escape("http://motherless.com"), "", mrtext);
386 mrtext_tmp = re.sub(re.escape("http://www.motherless.com"), "", mrtext_tmp);
387 mrtext_tmp = re.sub(re.escape("http://motherless.com"), "", mrtext_tmp);
388 mrtext_tmp = re.sub(re.escape("http://www.motherless.com"), "", mrtext_tmp);
389 mlesslinkone = re.findall(mregex_geturlone, mrtext_tmp);
390 if(getlinks[1]>len(mlesslinkone) or getlinks[1]==-1):
391 getlinks[1] = len(mlesslinkone);
392 if(getlinks[0]>getlinks[1] and not getlinks[1]==-1):
393 tmpgetlinks0 = getlinks[0];
394 tmpgetlinks1 = getlinks[1];
395 getlinks[0] = tmpgetlinks1;
396 getlinks[1] = tmpgetlinks0;
397 if(getlinks[0]<0):
398 getlinks[0] = 0;
399 mli = getlinks[0];
400 mlil = getlinks[1];
401 returnval = {'numoflinks': mlil};
402 returnval.update({'numofalllinks': len(mlesslinkone)});
403 returnval.update({'orginurl': httpurl});
404 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
405 mlessrooturltype = get_motherless_get_link_type(httpurl);
406 returnval.update({'urltype': mlessrooturltype});
407 while(mli<mlil):
408 mlessurltype = get_motherless_get_link_type("http://motherless.com/"+mlesslinkone[mli]);
409 returnval.update({mli: {'urltype': mlessurltype, 'url': "http://motherless.com/"+mlesslinkone[mli]} });
410 mli = mli + 1;
411 return returnval;
413 def get_motherless_search_members(httpurl, httpheaders, httpcookie, page=1, getlinks=[0, -1]):
414 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
415 mregex_getpagenum = re.escape("page=")+"([0-9]+)"+re.escape("\" class=\"pop\" rel=\"")+"([0-9]+)"+re.escape("\">")+"([0-9]+)"+re.escape("</a>");
416 mlesspagenum = re.findall(mregex_getpagenum, mrtext);
417 try:
418 lastpage = mlesspagenum[-1][0];
419 except:
420 lastpage = 1;
421 if(page>lastpage):
422 page = lastpage;
423 httpurl = add_url_param(httpurl, page=str(page));
424 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
425 mregex_getuname = re.escape("<tr rel=\"")+"([\w\/\?\&\=\.\-]+)"+re.escape("\"");
426 mlessuname = re.findall(mregex_getuname, mrtext);
427 mregex_geturlname = re.escape("<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re.escape("\" target=\"_blank\">\n <img");
428 mlessurlname = re.findall(mregex_geturlname, mrtext);
429 mregex_getavatar = re.escape("<img\n src=\"")+"(.*)"+re.escape("\"\n class=\"avatar avatar-small\"");
430 mlessavatar = re.findall(mregex_getavatar, mrtext);
431 if(getlinks[1]>len(mlesslinkone) or getlinks[1]==-1):
432 getlinks[1] = len(mlesslinkone);
433 if(getlinks[0]>getlinks[1] and not getlinks[1]==-1):
434 tmpgetlinks0 = getlinks[0];
435 tmpgetlinks1 = getlinks[1];
436 getlinks[0] = tmpgetlinks1;
437 getlinks[1] = tmpgetlinks0;
438 if(getlinks[0]<0):
439 getlinks[0] = 0;
440 mli = getlinks[0];
441 mlil = getlinks[1];
442 returnval = {'numoflinks': mlil};
443 returnval.update({'numofalllinks': len(mlessuname)});
444 returnval.update({'pages': lastpage});
445 returnval.update({'curpage': page});
446 returnval.update({'orginurl': httpurl});
447 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
448 mlessrooturltype = get_motherless_get_link_type(httpurl);
449 returnval.update({'urltype': mlessrooturltype});
450 while(mli<mlil):
451 avatarfilenameext = os.path.basename(urlparse.urljoin(mlessavatar[mli], urlparse.urlparse(mlessavatar[mli]).path));
452 avatarfilename, avatarfileextension = os.path.splitext(avatarfilenameext);
453 mlessurltype = get_motherless_get_link_type("http://motherless.com/"+mlessurlname[mli]);
454 returnval.update({mli: {'urltype': mlessurltype, 'url': "http://motherless.com/"+mlessurlname[mli], 'username': mlessuname[mli], 'avatarurl': mlessavatar[mli], 'avatarfullfilename': avatarfilenameext, 'avatarfilename': avatarfilename, 'avatarextension': avatarfileextension} });
455 mli = mli + 1;
456 return returnval;
458 def get_motherless_girls(httpurl, httpheaders, httpcookie, getlinks=[0, -1]):
459 mrtext = download_from_url(httpurl, httpheaders, httpcookie);
460 mregex_getuname = re.escape("<a href=\"")+"(.*)"+re.escape("\" rev=\"")+"([\w\/\?\&\=\.\-]+)"+re.escape("\" rel=\"")+"(.*)"+re.escape("\">");
461 mlessuname = re.findall(mregex_getuname, mrtext);
462 mregex_geturlname = re.escape("\n\t\t\t\t\t\t<a href=\"/m/")+"([\w\/\?\&\=\.\-]+)"+re.escape("\" target=\"_blank\">");
463 mlessurlname = re.findall(mregex_geturlname, mrtext);
464 if(getlinks[1]>len(mlesslinkone) or getlinks[1]==-1):
465 getlinks[1] = len(mlesslinkone);
466 if(getlinks[0]>getlinks[1] and not getlinks[1]==-1):
467 tmpgetlinks0 = getlinks[0];
468 tmpgetlinks1 = getlinks[1];
469 getlinks[0] = tmpgetlinks1;
470 getlinks[1] = tmpgetlinks0;
471 if(getlinks[0]<0):
472 getlinks[0] = 0;
473 mli = getlinks[0];
474 mlil = getlinks[1];
475 returnval = {'numoflinks': mlil};
476 returnval.update({'numofalllinks': len(mlessuname)});
477 returnval.update({'orginurl': httpurl});
478 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
479 mlessrooturltype = get_motherless_get_link_type(httpurl);
480 returnval.update({'urltype': mlessrooturltype});
481 while(mli<mlil):
482 avatarfilenameext = os.path.basename(urlparse.urljoin(mlessuname[mli][0], urlparse.urlparse(mlessuname[mli][0]).path));
483 avatarfilename, avatarfileextension = os.path.splitext(avatarfilenameext);
484 mlessurltype = get_motherless_get_link_type("http://motherless.com/"+mlessuname[mli][1]);
485 returnval.update({mli: {'urltype': mlessurltype, 'url': "http://motherless.com/"+mlessuname[mli][1], 'username': mlessuname[mli][1], 'usernamealt': mlessuname[mli][2], 'avatarurl': mlessuname[mli][0], 'avatarfullfilename': avatarfilenameext, 'avatarfilename': avatarfilename, 'avatarextension': avatarfileextension} });
486 mli = mli + 1;
487 return returnval;
489 def get_motherless_sample_links(httpheaders, httpcookie, numoflinks=10, urltype="video"):
490 if(urltype=="video"):
491 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])} };
492 if(urltype=="image"):
493 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])} };
494 if(urltype=="gallery"):
495 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])} };
496 if(urltype=="all"):
497 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])} };
498 return returnval;
500 def get_motherless_get_link_by_type(httpurl, httpheaders, httpcookie, page=1, getlinks=[0, -1]):
501 returnval = False;
502 if(get_motherless_get_link_type(httpurl)=="file"):
503 returnval = get_motherless_links(httpurl, httpheaders, httpcookie);
504 if(get_motherless_get_link_type(httpurl)=="gallery"):
505 returnval = get_motherless_galleries_links(httpurl, httpheaders, httpcookie, page);
506 if(get_motherless_get_link_type(httpurl)=="sample-videos"):
507 returnval = get_motherless_sample_links(httpheaders, httpcookie, 10, "video");
508 if(get_motherless_get_link_type(httpurl)=="sample-images"):
509 returnval = get_motherless_sample_links(httpheaders, httpcookie, 10, "image");
510 if(get_motherless_get_link_type(httpurl)=="sample-galleries"):
511 returnval = get_motherless_sample_links(httpheaders, httpcookie, 10, "gallery");
512 if(get_motherless_get_link_type(httpurl)=="sample"):
513 returnval = get_motherless_sample_links(httpheaders, httpcookie, 10, "all");
514 if(get_motherless_get_link_type(httpurl)=="board"):
515 returnval = get_motherless_boards_links(httpurl, httpheaders, httpcookie);
516 if(get_motherless_get_link_type(httpurl)=="member"):
517 returnval = get_motherless_search_members(httpurl, httpheaders, httpcookie, page);
518 if(get_motherless_get_link_type(httpurl)=="girls"):
519 returnval = get_motherless_girls(httpurl, httpheaders, httpcookie);
520 if(get_motherless_get_link_type(httpurl)=="download"):
521 returnval = httpurl;
522 return returnval;
524 def view_motherless_links(httpurl, httpheaders, httpcookie, viewerpro, prearg=[], proarg=[]):
525 commandlist = [viewerpro] + prearg;
526 commandlist = commandlist + [get_motherless_links(httpurl, httpheaders, httpcookie)['url']];
527 commandlist = commandlist + proarg;
528 mpvplaylistp = subprocess.Popen(commandlist, stdout=subprocess.PIPE, stderr=subprocess.PIPE);
529 mpvplayout, mpvplayerr = mpvplaylistp.communicate();
530 return True;
532 def download_motherless_links(httpurl, httpheaders, httpcookie, sleep=-1, outfile="-", outpath=os.getcwd(), usetitlename=False):
533 global geturls_download_sleep;
534 if(sleep<0):
535 sleep = geturls_download_sleep;
536 mlessurl = get_motherless_links(httpurl, httpheaders, httpcookie);
537 outputname = mlessurl['fullfilename'];
538 outpath = outpath.rstrip(os.path.sep);
539 if(usetitlename==True):
540 outputname = mlessurl['title'];
541 if(usetitlename=="-" and outfile=="-"):
542 outputname = "-";
543 if(usetitlename=="-" and not outfile=="-"):
544 outputname = outfile;
545 returnval = download_from_url_to_file(mlessurl['url'], httpheaders, httpcookie, outputname, outpath, sleep);
546 return returnval;
548 def download_motherless_links_by_type(httpurl, httpheaders, httpcookie, sleep=-1, outfile="-", outpath=os.getcwd(), usetitlename=False, page=1, getlinks=[0, -1]):
549 global geturls_download_sleep;
550 if(sleep<0):
551 sleep = geturls_download_sleep;
552 mlessurl = get_motherless_get_link_by_type(httpurl, httpheaders, httpcookie, page);
553 if(mlessurl['urltype']=="download"):
554 outputname = mlessurl['fullfilename'];
555 outpathname = outpath.rstrip(os.path.sep);
556 if(usetitlename==True):
557 outputname = mlessurl['title'];
558 if(usetitlename=="-" and outfile[mli]=="-"):
559 outputname = "-";
560 if(usetitlename=="-" and not outfile[mli]=="-"):
561 outputname = outfile;
562 returnval = download_from_url_to_file(mlessurl['url'], httpheaders, httpcookie, outputname, outpathname, sleep);
563 if(not mlessurl['urltype']=="download"):
564 returnval = mlessurl;
565 return returnval;
567 def download_motherless_galleries_links(httpurl, httpheaders, httpcookie, sleep=-1, outfile="-", outpath=os.getcwd(), usetitlename=False, page=1, getlinks=[0, -1]):
568 global geturls_download_sleep;
569 if(sleep<0):
570 sleep = geturls_download_sleep;
571 mlessgalleries = get_motherless_galleries_links(httpurl, httpheaders, httpcookie, page, getlinks);
572 mli = 0;
573 mlil = mlessgalleries['numoflinks'];
574 returnval = {'pages': mlessgalleries['pages']};
575 returnval.update({'numoflists': mlessgalleries['numoflinks']});
576 returnval.update({'curpage': mlessgalleries['curpage']});
577 returnval.update({'numoflinks': mlessgalleries['numoflinks']});
578 returnval.update({'numofalllinks': mlessgalleries['numofalllinks']});
579 returnval.update({'orginurl': httpurl});
580 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
581 while(mli<mlil):
582 mlesslink = get_motherless_links(mlessgalleries[mli]['url'], httpheaders, httpcookie);
583 outputname = mlesslink['fullfilename'];
584 outpath = outpath.rstrip(os.path.sep);
585 if(usetitlename==True):
586 outputname = mlesslink['title'];
587 if(usetitlename=="-" and outfile=="-"):
588 outputname = "-";
589 if(usetitlename=="-" and not outfile=="-"):
590 outputname = outfile;
591 returnval.update({mli: {'download': download_from_url_to_file(mlesslink['url'], httpheaders, httpcookie, outputname, outpath, sleep), 'linkinfo': mlesslink} });
592 mli = mli + 1;
593 return returnval;
595 def download_get_motherless_boards_links(httpurl, httpheaders, httpcookie, sleep=-1, outfile="-", outpath=os.getcwd(), usetitlename=False, getlinks=[0, -1]):
596 global geturls_download_sleep;
597 if(sleep<0):
598 sleep = geturls_download_sleep;
599 mlessgalleries = get_motherless_boards_links(httpurl, httpheaders, httpcookie, getlinks);
600 mli = 0;
601 mlil = mlessgalleries['numoflinks'];
602 returnval = {'numoflists': mlessgalleries['numoflinks']};
603 returnval.update({'numofalllinks': mlessgalleries['numofalllinks']});
604 returnval.update({'orginurl': httpurl});
605 returnval.update({'orginurltype': get_motherless_get_link_type(httpurl)});
606 while(mli<mlil):
607 mlesslink = get_motherless_links(mlessgalleries[mli]['url'], httpheaders, httpcookie);
608 outputname = mlesslink['fullfilename'];
609 outpath = outpath.rstrip(os.path.sep);
610 if(usetitlename==True):
611 outputname = mlesslink['title'];
612 if(usetitlename=="-" and outfile=="-"):
613 outputname = "-";
614 if(usetitlename=="-" and not outfile=="-"):
615 outputname = outfile;
616 returnval.update({mli: {'download': download_from_url_to_file(mlesslink['url'], httpheaders, httpcookie, outputname, outpath, sleep), 'linkinfo': mlesslink} });
617 mli = mli + 1;
618 return returnval;