Merge lp:~damoxc/entertainer/video_metadata_enhancements into lp:entertainer

Proposed by Damien Churchill
Status: Needs review
Proposed branch: lp:~damoxc/entertainer/video_metadata_enhancements
Merge into: lp:entertainer
Diff against target: 85 lines (+34/-5)
2 files modified
entertainerlib/backend/components/mediacache/video_metadata_search.py (+16/-5)
entertainerlib/tests/test_videometadatasearch.py (+18/-0)
To merge this branch: bzr merge lp:~damoxc/entertainer/video_metadata_enhancements
Reviewer Review Type Date Requested Status
Entertainer Release Team Pending
Review via email: mp+27567@code.launchpad.net

Description of the change

Adds checking of folder names to the video metadata search to allow for people to store videos with a path:

Futurama/Season 2/05 - Episode.avi

To post a comment you must log in.
415. By Damien Churchill

re-enable the imdb search

Unmerged revisions

415. By Damien Churchill

re-enable the imdb search

414. By Damien Churchill

add checking folder names to the video metadata search

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'entertainerlib/backend/components/mediacache/video_metadata_search.py'
2--- entertainerlib/backend/components/mediacache/video_metadata_search.py 2009-05-10 17:36:49 +0000
3+++ entertainerlib/backend/components/mediacache/video_metadata_search.py 2010-06-14 23:55:45 +0000
4@@ -47,7 +47,7 @@
5 except imdb.IMDbError:
6 raise IOError("Couldn't connect to IMDB server!")
7
8- def _parse_filename(self, filename):
9+ def _parse_filename(self, path):
10 """
11 Parse filename. Tries to get title of the movie/tv-series etc.
12
13@@ -60,15 +60,15 @@
14 movie_name_keyword_something.avi
15 movie.name.avi
16 etc.
17- @param filename: Path of the movie
18+ @param path: Path of the movie
19 @return: Title, season and episode
20 """
21 season = 0
22 episode = 0
23
24- # lowercase filename and remove the path and extension
25- filename = filename.lower()
26- filename = os.path.split(filename)[1]
27+ # lowercase path and get the filename minus extension
28+ path = path.lower()
29+ filename = os.path.basename(path)
30 filename = os.path.splitext(filename)[0]
31
32 # strip ., - and _ from filename
33@@ -91,6 +91,17 @@
34 filename = filename.strip()
35 season = match.group('season')
36 episode = match.group('episode')
37+ else:
38+ # quite likely that this is a Show/Season 1/05 Episode.avi
39+ if filename[0].isdigit():
40+ regexp = r'(?P<title>.*?)/[a-zA-Z]+\s+(?P<season>\d{1,2})/(?P<episode>\d{1,2})'
41+ match = re.search(regexp, path)
42+ if match:
43+ filename = match.group('title')
44+ filename = filename.strip()
45+ season = match.group('season')
46+ episode = match.group('episode')
47+
48
49 return filename, int(season), int(episode)
50
51
52=== modified file 'entertainerlib/tests/test_videometadatasearch.py'
53--- entertainerlib/tests/test_videometadatasearch.py 2010-04-03 15:01:03 +0000
54+++ entertainerlib/tests/test_videometadatasearch.py 2010-06-14 23:55:45 +0000
55@@ -22,12 +22,30 @@
56 self.video_metadata_search_serie = VideoMetadataSearch(serie)
57 self.assertEqual(self.video_metadata_search_serie.title, "futurama")
58
59+ def testSerieTitleDir(self):
60+ '''
61+ testSerieTitleDir - Ensures a serie title is returned correctly
62+ when specified by a parent directory.
63+ '''
64+ serie = "/home/user/videos/Futurama/Season 2/05 something.avi"
65+ self.video_metadata_search_serie = VideoMetadataSearch(serie)
66+ self.assertEqual(self.video_metadata_search_serie.title, "futurama")
67+
68 def testSerieSeason(self):
69 '''testSerieSeason - Ensures a serie season is returned correctly'''
70 serie = "/home/user/videos/Futurama s02e05 something.avi"
71 self.video_metadata_search_serie = VideoMetadataSearch(serie)
72 self.assertEqual(self.video_metadata_search_serie.season, 2)
73
74+ def testSerieSeasonDir(self):
75+ '''
76+ testSerieSeasonDir - Ensures a serie season is returned correctly
77+ when specified by a parent directory.
78+ '''
79+ serie = "/home/user/videos/Futurama/Season 2/05 something.avi"
80+ self.video_metadata_search_serie = VideoMetadataSearch(serie)
81+ self.assertEqual(self.video_metadata_search_serie.season, 2)
82+
83 def testSerieEpisode(self):
84 '''testSerieEpisode - Ensures a serie episode is returned correctly'''
85 serie = "/home/user/videos/Futurama s02e05 something.avi"

Subscribers

People subscribed via source and target branches