Ticket #7620: jamu_full_filename.patch

File jamu_full_filename.patch, 7.6 KB (added by voidtrance@…, 14 years ago)

Jamu full pathname patch

  • jamu.

    old new  
    12641264                        # foo.0103*
    12651265                        re.compile(u'''^(.+)[ \._\-]([0-9]{2})([0-9]{2,3})[\._ -][^\\/]*$''' , re.UNICODE),
    12661266                ]
     1267                self.config['fullname_parse'] = [
     1268                        # Title/Season 1/01 Subtitle
     1269                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1270                                   u'''(?P<seasno>[0-9]+)/(?P<epno>[0-9]+).+$''', re.UNICODE),
     1271                        # Title/Season 1/s01e01 Subtitle
     1272                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1273                                   u'''(?P<seasno>[0-9]+)/[Ss][0-9]+[Ee](?P<epno>[0-9]+).+$''', re.UNICODE),
     1274                        # Title/Season 1/1x01 Subtitle
     1275                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1276                                   u'''(?P<seasno>[0-9]+)/(?:(?P=seasno))[Xx](?P<epno>[0-9]+).+$''', re.UNICODE),
     1277                        # Title/Season 1/Title s01e01 Subtitle
     1278                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1279                                   u'''(?P<seasno>[0-9]+)/(?:(?P=seriesname))\ [Ss][0-9]+'''+
     1280                                   u'''[Ee](?P<epno>[0-9]+).+$''', re.UNICODE),
     1281                        # Title/Season 1/Title 1x01 Subtitle
     1282                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1283                                   u'''(?P<seasno>[0-9]+)/(?:(?P=seriesname))\ (?:(?P=seasno))'''+
     1284                                   u'''[Xx](?P<epno>[0-9]+).+$''', re.UNICODE),
     1285                        # Title/Season 1/Episode 1 Subtitle
     1286                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1287                                   u'''(?P<seasno>[0-9]+)/Episode\ (?P<epno>[0-9]+).+$''', re.UNICODE),
     1288                        # Title/Season 1/Season 1 Episode 1 Subtitle
     1289                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)/Season\ '''+
     1290                                   u'''(?P<seasno>[0-9]+)/Season\ (?:(?P=seasno))\ '''+
     1291                                   u'''Episode\ (?P<epno>[0-9]+).+$''', re.UNICODE),
     1292                        # Title Season 1/01 Subtitle
     1293                        re.compile(u'''^.+?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1294                                   u'''/(?P<epno>[0-9]+).+$''', re.UNICODE),
     1295                        # Title Season 1/s01e01 Subtitle
     1296                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1297                                   u'''/[Ss][0-9]+[Ee](?P<epno>[0-9]+).+''', re.UNICODE),
     1298                        # Title Season 1/1x01 Subtitle
     1299                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1300                                   u'''/(?:(?P=seasno))[Xx](?P<epno>[0-9]+).+$''', re.UNICODE),
     1301                        # Title Season 1/Title s01e01 Subtitle
     1302                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1303                                   u'''/(?:(?P=seriesname))\ [Ss][0-9]+[Ee](?P<epno>[0-9]+).+$''', re.UNICODE),
     1304                        # Title Season 1/Title 1x01 Subtitle
     1305                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1306                                   u'''/(?:(?P=seriesname))\ (?:(?P=seasno))[Xx](?P<epno>[0-9]+).+$''',
     1307                                   re.UNICODE),
     1308                        # Title Season 1/Episode 1 Subtitle
     1309                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1310                                   u'''/Episode\ (?P<epno>[0-9]+).+$''', re.UNICODE),
     1311                        # Title Season 1/Season 1 Episode 1 Subtitle
     1312                        re.compile(u'''^.*?/(?P<seriesname>[^/]+)\ Season\ (?P<seasno>[0-9]+)'''+
     1313                                   u'''/Season\ (?:(?P=seasno))\ Episode\ (?P<epno>[0-9]+).+$''', re.UNICODE)
     1314                        ]
    12671315        # end __init__
    12681316
    12691317        # Local variable
     
    27512799                                else:
    27522800                                        sys.stderr.write(u"\n! Warning: Skipping non-video file name: (%s)\n" % (f))
    27532801                                continue
    2754        
     2802
     2803                        match = None
    27552804                        for r in self.config['name_parse']:
    27562805                                match = r.match(filename)
    2757                                 categories=''
    2758                                 if match:
    2759                                         seriesname, seasno, epno = match.groups()
    2760 
    2761                             #remove ._- characters from name (- removed only if next to end of line)
    2762                                         seriesname = re.sub("[\._]|\-(?=$)", " ", seriesname).strip()
    2763                                         seasno, epno = int(seasno), int(epno)
     2806                                if match: break
     2807                        # If the filename does not match the default regular
     2808                        # expressions, try to match the file path + filename with the
     2809                        # extended fullpath regular expression so we can extract the
     2810                        # needed information out of the pathname
     2811                        if not match:
     2812                                for r in self.config['fullname_parse']:
     2813                                        match = r.match(os.path.join(filepath, filename))
     2814                                        if match: break
     2815                                       
     2816                        categories=''
     2817                        if match:
     2818                                self.config['log'].debug(u'matched reg:%s'%match.re.pattern)
     2819                                seriesname, seasno, epno = match.groups()
     2820
     2821                                #remove ._- characters from name (- removed only if next to end of line)
     2822                                seriesname = re.sub("[\._]|\-(?=$)", " ", seriesname).strip()
     2823                                seasno, epno = int(seasno), int(epno)
    27642824
    2765                                         if self.config['series_name_override']:
    2766                                                 if self.config['series_name_override'].has_key(seriesname.lower()):
    2767                                                         if len((self.config['series_name_override'][seriesname.lower()]).strip()) == 7:                                                         
    2768                                                                 categories+=u', Movie'
    2769                                                                 movie = filename
    2770                                                                 if movie.endswith(self.config['hd_dvd']):
    2771                                                                         movie = movie.replace(self.config['hd_dvd'], '')
     2825                                if self.config['series_name_override']:
     2826                                        if self.config['series_name_override'].has_key(seriesname.lower()):
     2827                                                if len((self.config['series_name_override'][seriesname.lower()]).strip()) == 7:                                                         
     2828                                                        categories+=u', Movie'
     2829                                                        movie = filename
     2830                                                        if movie.endswith(self.config['hd_dvd']):
     2831                                                                movie = movie.replace(self.config['hd_dvd'], '')
     2832                                                                categories+=u', DVD'
     2833                                                                categories+=u', HD'
     2834                                                        else:
     2835                                                                if movie.endswith(self.config['dvd']):
     2836                                                                        movie = movie.replace(self.config['dvd'], '')
    27722837                                                                        categories+=u', DVD'
    2773                                                                         categories+=u', HD'
    2774                                                                 else:
    2775                                                                         if movie.endswith(self.config['dvd']):
    2776                                                                                 movie = movie.replace(self.config['dvd'], '')
    2777                                                                                 categories+=u', DVD'
    2778                                                                 movie = re.sub("[\._]|\-(?=$)", " ", movie).strip()
    2779                                                                 try:
    2780                                                                         allEps.append({ 'file_seriesname':movie,
    2781                                                                                                         'seasno':0,
    2782                                                                                                         'epno':0,
    2783                                                                                                         'filepath':filepath,
    2784                                                                                                         'filename':filename,
    2785                                                                                                         'ext':ext,
    2786                                                                                                         'categories': categories
    2787                                                                                                         })
    2788                                                                 except UnicodeDecodeError:
    2789                                                                         allEps.append({ 'file_seriesname':unicode(movie,'utf8'),
    2790                                                                                                         'seasno':0,
    2791                                                                                                         'epno':0,
    2792                                                                                                         'filepath':unicode(filepath,'utf8'),
    2793                                                                                                         'filename':unicode(filename,'utf8'),
    2794                                                                                                         'ext':unicode(ext,'utf8'),
    2795                                                                                                         'categories': categories
    2796                                                                                                         })
    2797                                                                 break
    2798 
    2799                                         categories+=u', TV Series'
    2800                                         try:
    2801                                                 allEps.append({ 'file_seriesname':seriesname,
    2802                                                                                 'seasno':seasno,
    2803                                                                                 'epno':epno,
     2838                                                        movie = re.sub("[\._]|\-(?=$)", " ", movie).strip()
     2839                                                        try:
     2840                                                                allEps.append({ 'file_seriesname':movie,
     2841                                                                                'seasno':0,
     2842                                                                                'epno':0,
    28042843                                                                                'filepath':filepath,
    28052844                                                                                'filename':filename,
    28062845                                                                                'ext':ext,
    28072846                                                                                'categories': categories
    28082847                                                                                })
    2809                                         except UnicodeDecodeError:
    2810                                                 allEps.append({ 'file_seriesname':unicode(seriesname,'utf8'),
    2811                                                                                 'seasno':seasno,
    2812                                                                                 'epno':epno,
     2848                                                        except UnicodeDecodeError:
     2849                                                                allEps.append({ 'file_seriesname':unicode(movie,'utf8'),
     2850                                                                                'seasno':0,
     2851                                                                                'epno':0,
    28132852                                                                                'filepath':unicode(filepath,'utf8'),
    28142853                                                                                'filename':unicode(filename,'utf8'),
    28152854                                                                                'ext':unicode(ext,'utf8'),
    28162855                                                                                'categories': categories
    28172856                                                                                })
    2818                                         break # Matched - to the next file!
     2857
     2858                                categories+=u', TV Series'
     2859                                try:
     2860                                        allEps.append({ 'file_seriesname':seriesname,
     2861                                                        'seasno':seasno,
     2862                                                        'epno':epno,
     2863                                                        'filepath':filepath,
     2864                                                        'filename':filename,
     2865                                                        'ext':ext,
     2866                                                        'categories': categories
     2867                                                        })
     2868                                except UnicodeDecodeError:
     2869                                        allEps.append({ 'file_seriesname':unicode(seriesname,'utf8'),
     2870                                                        'seasno':seasno,
     2871                                                        'epno':epno,
     2872                                                        'filepath':unicode(filepath,'utf8'),
     2873                                                        'filename':unicode(filename,'utf8'),
     2874                                                        'ext':unicode(ext,'utf8'),
     2875                                                        'categories': categories
     2876                                                        })
    28192877                        else:
    28202878                                if movies: # Account for " - On DVD" and " HD - On DVD" extra text on file names
    28212879                                        categories+=u', Movie'