def getMovieLens(url): req = urllib2.Request(url) req.add_header('User-Agent', "%s %s" % (sys.modules[ "__main__" ].__plugin__, sys.modules[ "__main__" ].__version__)) response = urllib2.urlopen(req) soup = BeautifulSoup(response) mySpans= soup.findAll('span',attrs={"class" : "movieTitle"}) ##mySpans = mySpans[1], mySpans[2] mydirs = list() pDialog = xbmcgui.DialogProgress() ret = pDialog.create('XBMC', 'Initializing script...') i = 0.0 total = len(mySpans) for span in mySpans: i += 1 percent = int( (i * 100) / total) pDialog.update(percent, 'Searching ' + span.a.string,str(int(i))+'/'+str(total)) s = span.a.string year = s[len(s)-7 : len(s)] year = year.replace('(','').replace(')','') year = year.strip() s = s.split('(',1)[0].strip() s = s.replace(', The','') #print s xbmc.log('s=%s' % s) dirs= getter.searchDirs(s + ' ' + year) if dirs: for d in dirs: id = d.getElementsByTagName('id').item(0).firstChild.data name = d.getElementsByTagName('name').item(0).firstChild.data date = d.getElementsByTagName('date').item(0).firstChild.data thumb = d.getElementsByTagName('thumb').item(0).firstChild.data url = sys.argv[0] + '?action=files&did=' + id clean = CleanFileName(name,False) clean = clean.replace('(', '') clean = clean.replace('[', '') clean = clean.replace(']', '') clean = clean.replace(')', '') if s.lower() in clean.lower() and year in name: ##xbmc.log('name=%s' % name) mydirs.append(d) if (pDialog.iscanceled()): print 'Canceled search' pDialog.close() return pDialog.close() return mydirs
def getFeed(url): d = feedparser.parse(url) for entry in d['entries']: print entry.title propername,dummy = nameCheck(entry.title,'') dirs= getter.searchDirs(propername) d= dirs[0] if d: id = d.getElementsByTagName('id').item(0).firstChild.data name = d.getElementsByTagName('name').item(0).firstChild.data date = d.getElementsByTagName('date').item(0).firstChild.data thumb = d.getElementsByTagName('thumb').item(0).firstChild.data files = getter.getFiles(id) printer.addFiles(files)