def getReal(self, real): self.content = "" self.simi = "" for mov in self.parcourir(): print mov inf = self.nfoparse(mov) if "director" in inf: for di in inf["director"]: if pidevs.nospachar(di) == real: self.content += self.show(inf) elif LEVEN and Levenshtein.distance( pidevs.cleantext(pidevs.nospachar(di)), pidevs.cleantext(real)) < 5: self.simi += " LEV " + pidevs.cleantext(pidevs.nospachar(di)) + " - " + pidevs.cleantext(real) + " = " + Levenshtein.distance(pidevs.cleantext(pidevs.nospachar(di)), pidevs.cleantext(real)) self.simi += self.show(inf) else: pass html = "<h2> Real : " + real + " </h2> " + self.content if LEVEN: html += " <hr> <h2> Similaires </h2> " + self.simi return html
def view(self): self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() env = Environment(loader=FileSystemLoader('%s' % os.path.dirname(__file__))) template = env.get_template('html/index.htm') self.content = template.render(DOMA=DOMA, content=self.content, title=self.title, ndbmv=self.ndbmovies) self.content = pidevs.cleantext(self.content) self.wfile.write(self.content) return
def dbcall(req, keydb): #url = "https://api.themoviedb.org/3/search/movie/language=fr&api_key=" + keydb mots = req.split() mots2 = [] for m in mots: try: int(m) break except: if m.lower() not in ['vo', 'vostfr', 'dvdrip', 'brrip', '720p', '1080p', 'wawa', 'xvid', 'www']: m = pidevs.cleantext(m) mots2.append(m) else: break print( mots2) #req = req.findall(r'[A-Z]+[^A-Z]*', str) params = {'api_key':keydb, "query" : ' '.join(mots2), 'language' : 'fr'} query = urllib.parse.urlencode(params) url = "https://api.themoviedb.org/3/search/movie?" + query headers = { 'Accept': 'application/json' } request = urllib.request.Request(url, headers=headers) #print( url) response_body = urllib.request.urlopen(request).read() #print( response_body) data = json.loads(response_body) #print( data) #for i, j in data.items() : # print( i) print( " >> " + str(data['total_results']) + " R") results = [{'empty':False, 'id':i['id'], 'title':i['original_title'], 'year':str(i['release_date']).split('-')[0].strip()} for i in data['results']] results_year = [x for x in results if x['year'] != "" and x['year'] in req] if len(results) == 0: return False if len(results) == 1: return results[0] if len(results_year) == 1: return results_year[0] for i,res in enumerate(results): print( str(i) + " : " + res['year'] + " - " + res['title'] ) i = raw_input("Which one (x to pass) $ ") try: return results[int(i)] except Exception as inst: return False