Custom Scanner : Use imdbid in filename instead of name and year

Hello,

 

as I couldn't find any scanner that first searches for the IMDBID in the filename I tried to build one myself.

My Media collection is named like this: "The title (IMDBID) - format.ts" where "format" is "SD,HD or 3D".

 

I would be very pleased if some of you could check my programming skills, as I don't have any! ;-)

 

I would do it like this:

--------------------------------------------------------------------------------------------------------------------------------------------------------------

#
# Custom Movie Scanner for Mediafiles including the IMDBID
#----------------------------------------------------------
# This scanner uses the IMDBID in the filename instead of the movie name!
#
import re, os, os.path, sys, datetime
import Media, VideoFiles, unicodedata

def Scan(path, files, mediaList, subdirs):

    # If files are "valid"
  if len(files) >= 1:

    
    # Iterate through all the files
    for file in files:

      # Example file format:
      # Die Huberbuam 3D (tt2363242) - 3D.ts
      # Check if its really a *.ts file:
      if (file.endswith(".ts")):

        # Remove path:
        tsfile = os.path.basename(file)
        # C:\Filme\Spielfilme\3D\Die Huberbuam 3D (tt2363242) - 3D.ts -> Die Huberbuam 3D (tt2363242) - 3D.ts
        
        # Remove extension:
        tsfile = os.path.splitext(tsfile)[0]
        # Die Huberbuam 3D (tt2363242) - 3D.ts -> Die Huberbuam 3D (tt2363242) - 3D

        # Search for the beginning of the IMDBID and save it in i:
        i = str.rfind(' (tt')
        
        # Add two to start with tt...:
        i=i+2
        
        # Search for the end of the IMDBID and save it in j:
        j = str.rfind(') ')
        
        # Save the part beginning at i and ending at j of tsfile in imdbid:
        imdbid = tsfile[i:j]
        
        year = None    # no entry for year
        name = imdbid
        
        print "adding movie", (name), "year", (year)
        movie = Media.Movie(name, year)
        movie.source = VideoFiles.RetrieveSource(file)
        movie.parts.append(file)
        mediaList.append(movie)
 

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------

 

Any useful hints are very welcome!

 

Thanks a lot!

 

Regards

Hossa

Thanks for those many hints! ;-)

I got it up and running, just a few small changes in the script. It has to be like this:

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#
# Custom Movie Scanner for Mediafiles including the IMDBID
#----------------------------------------------------------
# This scanner uses the IMDBID in the filename instead of the movie name!
#
import re, os, os.path, sys, datetime
import Media, VideoFiles, unicodedata

def Scan(path, files, mediaList, subdirs):

    # If files are "valid"
  if len(files) >= 1:

    
    # Iterate through all the files
    for file in files:

      # Example file format:
      # Die Huberbuam 3D (tt2363242) - 3D.ts
      # Check if its really a *.ts file:
      if (file.endswith(".ts")):

        # Remove path:
        tsfile = os.path.basename(file)
        # C:\Filme\Spielfilme\3D\Die Huberbuam 3D (tt2363242) - 3D.ts -> Die Huberbuam 3D (tt2363242) - 3D.ts
        
        # Remove extension:
        tsfile = os.path.splitext(tsfile)[0]
        # Die Huberbuam 3D (tt2363242) - 3D.ts -> Die Huberbuam 3D (tt2363242) - 3D

        # Search for the beginning of the IMDBID and save it in i:
        i = tsfile.rfind(" (tt")
        
        # Add two to start with tt...:
        i=i+2
        
        # Search for the end of the IMDBID and save it in j:
        j = tsfile.rfind(") ")
        
        # Save the part beginning at i and ending at j of tsfile in imdbid:
        imdbid = tsfile[i:j]
        
        year = None    # no entry for year
        name = imdbid
        
        print "adding movie", (name), "year", (year)
        movie = Media.Movie(name, year)
        movie.source = VideoFiles.RetrieveSource(file)
        movie.parts.append(file)
        mediaList.append(movie)

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

So far I tested it with a folder of 43 files, and only two didn't work correctly. So I will try to find out, what is going wrong there!

UPDATE: Two didn't work, because I did not have an IMDBID in the filename!! :-)

Hope I can help others with providing this code! :-)

Regards

Hossa

Movie scanner looks for tt* in .nfo for some time now, here is the code in "Plex Movie Scanner.py"

Hello gits,

thanks for your code!

But I didn't want to create a *.nfo file for EACH of my movie files......as there are MANY in one folder. So no solution for me.

But as I am having trouble with identifying multiple episodes in one "DVD Image = Name of Series/Name of Series SxxEyy-Ezz"

I think I may "missuse" your code a little modified and than make a *nfo file for each disk!

Anyways, nice work!

Cheers

Hossa

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.