L4GSP1KE / Upload-Assistant

311 stars 107 forks source link

[Feature Request] Improve Matching By Using TMDB and IMDB from mediainfo if available #14

Closed ghost closed 2 years ago

ghost commented 2 years ago

Title says it all.

Recently had something match incorrectly and it included tmdb and imdb IDs in mediainfo.

I'm sure there are better ways to do this but I am VERY rusty with regex and python

from pymediainfo import MediaInfo
import re 

# Parse MediaInfo
media_info = MediaInfo.parse(filename="filename", output="STRING", full=False, mediainfo_options={'inform_version' : '1'})

# Get IMDB
imdb_line = re.search("(?:IMDB[ \t]+: tt[ \d]+)", media_info)
imdb_id = imdb_line.group().replace("IMDB                                     : ", "")
# imdb_id = tt01234
if imdb_id is None:
    # handle like you currently do

# Get TMDB
tmdb_line = re.search("(?:TMDB[ \t]+: .*)", media_info)
tmdb_id = tmdb_line.group().replace("TMDB                                     : ", "")  
# tmdb_id = movie/01234
if tmdb_id is None:
    # handle like you currently do
L4GSP1KE commented 2 years ago

Implemented.