Ticket #6219: imdb_script3.patch
File imdb_script3.patch, 4.4 KB (added by , 16 years ago) |
---|
-
imdbpy.py
327 327 shortest_found = None 328 328 #print "%d plots found" % len(plots) 329 329 for plot in plots: 330 text = plot.split("::")[1] 330 #IMDbPY 3.9 doesn't order the content of plot like earlier version of IMDbPY. 331 # IMDB 3.6 is : plot_content::author 332 # IMDB 3.9 is : author::plot_content 333 #So we assume that should one side longer than the other, it's actually where the description is 334 splitvalue = plot.split("::") 335 if len(splitvalue[0]) > len(splitvalue[1]): 336 text = splitvalue[0] 337 else: 338 text = splitvalue[1] 331 339 if shortest_found == None or len(text) < len(shortest_found): 332 340 shortest_found = text 333 341 metadata.plot = shortest_found … … 397 405 398 406 if options.movie_search is not None: 399 407 results = title_search(options.movie_search.decode("utf8")) 400 for result in results: 401 print "%s:%s (%d)" % (result[0], result[1], result[2]) 408 if results: 409 for result in results: 410 print "%s:%s (%d)" % (result[0], result[1], result[2]) 402 411 elif options.poster_search is not None: 403 412 poster_search(options.poster_search) 404 413 elif options.metadata_search is not None: -
fetch_poster.py
189 189 190 190 if imdb_id is None: 191 191 return [] 192 poster_url = imdbpy.find_poster_url(imdb_id) 192 try: 193 poster_url = imdbpy.find_poster_url(imdb_id) 194 except: 195 #IMDb often timesout or return an error 503... try again just in case 196 poster_url = imdbpy.find_poster_url(imdb_id) 193 197 if poster_url is not None: 194 198 filename = poster_url.split("/")[-1] 195 199 (name, extension) = os.path.splitext(filename) … … 254 258 if len(arguments) != 1: 255 259 if options.imdb_id: 256 260 # TODO: Fetch the title from IMDb. 257 metadata = imdbpy.metadata_search(options.imdb_id) 261 try: 262 metadata = imdbpy.metadata_search(options.imdb_id) 263 except: 264 #IMDb often timesout or return an error 503... try again just in case 265 metadata = imdbpy.metadata_search(options.imdb_id) 258 266 title = imdbpy.parse_meta(metadata, "Title") 259 267 else: 260 268 print "Please give a video title as argument." -
find_meta.py
153 153 lowest_cutpoint = pos 154 154 155 155 title = title[0:lowest_cutpoint] 156 # Remove trailing year in the form of "name [year]" or "name (year)"if any 157 m = re.compile(r"(.*)([\(\[]([0-9]+)[\]\)])$") 158 found = m.match(title.strip()) 159 if found: 160 title = found.group(1) 156 161 return title.strip() 157 162 158 163 def parse_meta(variable, oldvalue, emptyvalue="", meta=""): … … 528 533 529 534 print_verbose("Title search '%s'" % title) 530 535 531 candidates = imdbpy.title_search(title) 536 try: 537 candidates = imdbpy.title_search(title) 538 except: 539 #IMDb often timesout or return an error 503... try again just in case 540 candidates = imdbpy.title_search(title) 541 532 542 if candidates is None or len(candidates) == 0: 533 543 # TODO: Try with the dirname 534 544 pass … … 560 570 561 571 print_verbose("Querying IMDb for meta data for ID %s..." % imdb_id) 562 572 try: 563 meta = imdbpy.fetch_metadata(imdb_id) 573 try: 574 meta = imdbpy.fetch_metadata(imdb_id) 575 except: 576 #IMDb often timesout or return an error 503... try again just in case 577 meta = imdbpy.fetch_metadata(imdb_id) 564 578 if meta is not None: 565 579 if meta.series_episode: 566 580 title, season, episode = imdbpy.detect_series_title(title) … … 708 722 metadata = load_metadata_file(metadata_target) 709 723 710 724 if imdb_id is not None: 711 meta = imdbpy.fetch_metadata(imdb_id) 725 try: 726 meta = imdbpy.fetch_metadata(imdb_id) 727 except: 728 #IMDb often timesout or return an error 503... try again just in case 729 meta = imdbpy.fetch_metadata(imdb_id) 712 730 if meta.series_episode: 713 731 fileName = os.path.basename(pathName) 714 732 t, season, episode = imdbpy.detect_series_title(fileName) … … 734 752 return 735 753 736 754 if imdb_id is not None: 737 metadata = imdbpy.metadata_search(imdb_id) 755 try: 756 metadata = imdbpy.metadata_search(imdb_id) 757 except: 758 #IMDb often timesout or return an error 503... try again just in case 759 metadata = imdbpy.metadata_search(imdb_id) 738 760 if metadata is not None: 739 761 metadata += "IMDb:%s" % imdb_id + "\n" 740 762 save_metadata(dirName, dirName + "/video.metadata", metadata)