# strip ., - and _ from filename
- for item in self.__TITLE_STRIP_SEARCH:
+ for item in self._TITLE_STRIP_SEARCH: filename = filename.replace(item, ' ')
# split title at keywords
- for item in self.__TITLE_SPLIT_KEYWORDS:
+ for item in self._TITLE_SPLIT_KEYWORDS: filename = filename.split('%s' % item)[0]
filename = filename.strip()
@@ -107,7 +105,6 @@
except: self.logger.error("IMDB search failed")
return # Network error or too many results to handle
-
if len(search_results) == 0:
return # No matches for this search
@@ -122,11 +119,16 @@ return
video_type = "MOVIE"
+
try: title = movie['title'] year = movie['year']
- # convert to 5-stars rating
- rating = round(float(movie['rating']) / 2)
+
+ # convert to 5-star ratings if available
+ try:
+ rating = round(float(movie['rating']) / 2)
+ except KeyError:
+ rating = 0
This branch fixes three small things:- metadata searching for movies failed because ratings aren't being downloaded from imdb anymore.
- When a tv-show episode didn't have a title the title was '1. 1. Episode', now it's '1. Episode 1'
- Videos weren't playing because of a typing error: mediaplayer instead of media_player
I fixed the double underscore, the trailing whitespace, 5 star ratings and the exception catching.
There is already a test for all of this: test_videometadatasearch.py
Ok, first the diff against trunk
=== modified file 'entertainerlib /backend/ components/ mediacache/ video_metadata_ search. py' backend/ components/ mediacache/ video_metadata_ search. py 2008-12-07 20:41:05 +0000 backend/ components/ mediacache/ video_metadata_ search. py 2009-02-07 20:06:05 +0000
--- entertainerlib/
+++ entertainerlib/
@@ -23,14 +23,12 @@
"""
# Title split keywords SPLIT_KEYWORDS = [ SPLIT_KEYWORDS = ["[", "]", "~", "(", ")", "dvdscr", "dvdrip",
- __TITLE_
- "[", "]", "~", "(", ")", "dvdscr", "dvdrip", "dvd-rip", "dvdr", "vcd",
- "divx", "xvid", "ac3", "r5", "pal", "readnfo", "uncut", "cd1", "cd2",
- "dvdiso"
- ]
+ _TITLE_
+ "dvd-rip", "dvdr", "vcd", "divx", "xvid", "readnfo", "cd1", "cd2",
+ "dvdiso"]
# Title strip items STRIP_SEARCH = [".", "-", "_"]
- __TITLE_
+ _TITLE_STRIP_SEARCH = [".", "-", "_"]
def __init__(self, filename): splitext( filename) [0]
"""
@@ -75,11 +73,11 @@
filename = os.path.
# strip ., - and _ from filename TITLE_STRIP_ SEARCH: STRIP_SEARCH:
filename = filename. replace( item, ' ')
- for item in self.__
+ for item in self._TITLE_
# split title at keywords TITLE_SPLIT_ KEYWORDS: SPLIT_KEYWORDS:
filename = filename.split('%s' % item)[0]
- for item in self.__
+ for item in self._TITLE_
filename = filename.strip()
@@ -107,7 +105,6 @@
self. logger. error(" IMDB search failed")
except:
return # Network error or too many results to handle
-
if len(search_results) == 0:
return # No matches for this search
@@ -122,11 +119,16 @@
return
+
try:
- # convert to 5-stars rating
- rating = round(float(
+
+ # convert to 5-star ratings if available
+ try:
+ rating = round(float(
+ except KeyError:
+ rating = 0
@@ -199,7 +201,7 @@
try:
- title = _("%(episode)d. Episode") % {'episode': self.episode}
+ title = _(" Episode %(episode)d") % {'episode': self.episode}
try:
=== modified file 'entertainerlib /frontend/ gui/screens/ movie.py' frontend/ gui/screens/ movie.py 2009-02-03 23:37:57 +0000 frontend/ gui/screens/ movie.py 2009-02-07 15:18:47 +0000 is_active( ):
item = self.menu. get_current_ menuitem( ).get_userdata( ) r.set_media( self.movie) r.play( ) player. set_media( self.movie) player. play()
self.callback( "video_ osd")
--- entertainerlib/
+++ entertainerlib/
@@ -212,7 +212,7 @@
if self.menu.
if item == "watch":
- self.mediaplaye
- self.mediaplaye
+ self.media_
+ self.media_
=== modified file 'entertainerlib /frontend/ gui/screens/ tv_episodes. py' frontend/ gui/screens/ tv_episodes. py 2009-02-03 23:37:57 +0000 frontend/ gui/screens/ tv_episodes. py 2009-02-07 15:15:25 +0000
self. scroll_ area.scroll_ page_down( ) NAVIGATE_ SELECT:
episode = self.episode_ menu.get_ current_ menuitem( ).get_userdata( ) r.set_media( episode) r.play( ) player. set_media( episode) player. play()
self. callback( "video_ osd")
--- entertainerlib/
+++ entertainerlib/
@@ -199,7 +199,7 @@
elif event_type == UserEvent.
- self.mediaplaye
- self.mediaplaye
+ self.media_
+ self.media_
This branch fixes three small things:- metadata searching for movies failed because ratings aren't being downloaded from imdb anymore.
- When a tv-show episode didn't have a title the title was '1. 1. Episode', now it's '1. Episode 1'
- Videos weren't playing because of a typing error: mediaplayer instead of media_player
I fixed the double underscore, the trailing whitespace, 5 star ratings and the exception catching. atasearch. py
There is already a test for all of this: test_videometad