From a466cbcf16e19687a970f52d38ad28b7bc3b6e83 Mon Sep 17 00:00:00 2001 From: mano3m Date: Tue, 19 Nov 2013 16:13:22 +0100 Subject: [PATCH 1/7] [Metadata][XBMC] Fix nfo data Fixes #1412 and @Lennong MPAA section --- couchpotato/core/providers/metadata/xbmc/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 7073363..5603279 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -65,7 +65,7 @@ class XBMC(MetaDataBase): name = type try: - if data['library'].get(type): + if movie_info.get(type): el = SubElement(nfoxml, name) el.text = toUnicode(movie_info.get(type, '')) except: From 2c1c57333c4b3e5af12cc3ecabfc092590d3406e Mon Sep 17 00:00:00 2001 From: mano3m Date: Tue, 19 Nov 2013 16:30:56 +0100 Subject: [PATCH 2/7] [Metadata][XBMC] Add trailer to nfo --- couchpotato/core/providers/metadata/xbmc/main.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 5603279..e287cbd 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -112,6 +112,18 @@ class XBMC(MetaDataBase): sorttitle = SubElement(nfoxml, 'sorttitle') sorttitle.text = '%s %s' % (toUnicode(collection_name), movie_info.get('year')) + # Add trailer if found + trailer_found = False + if data.get('renamed_files'): + for filename in data.get('renamed_files'): + if 'trailer' in filename: + trailer = SubElement(nfoxml, 'trailer') + trailer.text = toUnicode(filename) + trailer_found = True + if not trailer_found and data['files'].get('trailer'): + trailer = SubElement(nfoxml, 'trailer') + trailer.text = toUnicode(data['files']['trailer'][0]) + # Clean up the xml and return it nfoxml = xml.dom.minidom.parseString(tostring(nfoxml)) xml_string = nfoxml.toprettyxml(indent = ' ') From bd1bb1ee9172d91666cc91fdd783c7c6ec4dd872 Mon Sep 17 00:00:00 2001 From: mano3m Date: Tue, 19 Nov 2013 18:30:09 +0100 Subject: [PATCH 3/7] [Metadata][XBMC] Add images to nfo --- couchpotato/core/providers/metadata/xbmc/main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index e287cbd..09e523a 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -112,6 +112,15 @@ class XBMC(MetaDataBase): sorttitle = SubElement(nfoxml, 'sorttitle') sorttitle.text = '%s %s' % (toUnicode(collection_name), movie_info.get('year')) + # Images + for image_url in movie_info['images']['poster_original']: + image = SubElement(nfoxml, 'thumb') + image.text = toUnicode(image_url) + fanart = SubElement(nfoxml, 'fanart') + for image_url in movie_info['images']['backdrop_original']: + image = SubElement(fanart, 'thumb') + image.text = toUnicode(image_url) + # Add trailer if found trailer_found = False if data.get('renamed_files'): From e4993eac24d7c6d376ef9183fa84096217e0f447 Mon Sep 17 00:00:00 2001 From: mano3m Date: Wed, 20 Nov 2013 00:32:26 +0100 Subject: [PATCH 4/7] [Metadata][XBMC] Add actors to CPS info and nfo --- couchpotato/core/providers/info/omdbapi/main.py | 2 +- couchpotato/core/providers/info/themoviedb/main.py | 21 +++++++++++++++------ couchpotato/core/providers/metadata/xbmc/main.py | 14 ++++++++++---- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/couchpotato/core/providers/info/omdbapi/main.py b/couchpotato/core/providers/info/omdbapi/main.py index 47374f4..c5db5ea 100755 --- a/couchpotato/core/providers/info/omdbapi/main.py +++ b/couchpotato/core/providers/info/omdbapi/main.py @@ -105,7 +105,7 @@ class OMDBAPI(MovieProvider): 'genres': splitString(movie.get('Genre', '')), 'directors': splitString(movie.get('Director', '')), 'writers': splitString(movie.get('Writer', '')), - 'actors': splitString(movie.get('Actors', '')), + 'actors': [{actor: ''} for actor in splitString(movie.get('Actors', ''))], } movie_data = dict((k, v) for k, v in movie_data.iteritems() if v) except: diff --git a/couchpotato/core/providers/info/themoviedb/main.py b/couchpotato/core/providers/info/themoviedb/main.py index a790135..cb44f6d 100644 --- a/couchpotato/core/providers/info/themoviedb/main.py +++ b/couchpotato/core/providers/info/themoviedb/main.py @@ -92,6 +92,13 @@ class TheMovieDb(MovieProvider): poster_original = self.getImage(movie, type = 'poster', size = 'original') backdrop_original = self.getImage(movie, type = 'backdrop', size = 'original') + images = { + 'poster': [poster] if poster else [], + #'backdrop': [backdrop] if backdrop else [], + 'poster_original': [poster_original] if poster_original else [], + 'backdrop_original': [backdrop_original] if backdrop_original else [], + } + # Genres try: genres = [genre.name for genre in movie.genres] @@ -103,18 +110,19 @@ class TheMovieDb(MovieProvider): if not movie.releasedate or year == '1900' or year.lower() == 'none': year = None + # Gather actors data + actors = [] + for cast_item in movie.cast: + actors.append({toUnicode(cast_item.name): toUnicode(cast_item.character)}) + images.append({'actor %s' % toUnicode(cast_item.name): self.getImage(cast_item, type = 'profile', size = 'original')}) + movie_data = { 'type': 'movie', 'via_tmdb': True, 'tmdb_id': movie.id, 'titles': [toUnicode(movie.title)], 'original_title': movie.originaltitle, - 'images': { - 'poster': [poster] if poster else [], - #'backdrop': [backdrop] if backdrop else [], - 'poster_original': [poster_original] if poster_original else [], - 'backdrop_original': [backdrop_original] if backdrop_original else [], - }, + 'images': images, 'imdb': movie.imdb, 'runtime': movie.runtime, 'released': str(movie.releasedate), @@ -122,6 +130,7 @@ class TheMovieDb(MovieProvider): 'plot': movie.overview, 'genres': genres, 'collection': getattr(movie.collection, 'name', None), + 'actors': actors } movie_data = dict((k, v) for k, v in movie_data.iteritems() if v) diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 09e523a..659139b 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -89,10 +89,16 @@ class XBMC(MetaDataBase): genres.text = toUnicode(genre) # Actors - for actor in movie_info.get('actors', []): - actors = SubElement(nfoxml, 'actor') - name = SubElement(actors, 'name') - name.text = toUnicode(actor) + for actor_name, role_name in movie_info.get('actors', {}): + actor = SubElement(nfoxml, 'actor') + name = SubElement(actor, 'name') + name.text = toUnicode(actor_name) + if role_name: + role = SubElement(actor, 'role') + role.text = toUnicode(role_name) + if movie_info['images'].get('actor %s' % actor_name, ''): + thumb = SubElement(actor, 'thumb') + thumb.text = toUnicode(movie_info['images'].get('actor %s' % actor_name)) # Directors for director_name in movie_info.get('directors', []): From 1b5bc1fa05812e0e82ff5e8cd7656a8113a76a48 Mon Sep 17 00:00:00 2001 From: mano3m Date: Thu, 21 Nov 2013 00:43:17 +0100 Subject: [PATCH 5/7] [Metadata][XBMC] Add fileinfo to nfo Also fixed a int / int = int divide bug --- couchpotato/core/plugins/scanner/main.py | 2 +- couchpotato/core/providers/metadata/xbmc/main.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index eb193ad..24eb7ac 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -454,7 +454,7 @@ class Scanner(Plugin): data['resolution_width'] = meta.get('resolution_width', 720) data['resolution_height'] = meta.get('resolution_height', 480) data['audio_channels'] = meta.get('audio_channels', 2.0) - data['aspect'] = meta.get('resolution_width', 720) / meta.get('resolution_height', 480) + data['aspect'] = round(float(meta.get('resolution_width', 720)) / meta.get('resolution_height', 480), 2) except: log.debug('Error parsing metadata: %s %s', (cur_file, traceback.format_exc())) pass diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 659139b..0d853df 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -139,6 +139,30 @@ class XBMC(MetaDataBase): trailer = SubElement(nfoxml, 'trailer') trailer.text = toUnicode(data['files']['trailer'][0]) + # Add file metadata + fileinfo = SubElement(nfoxml, 'fileinfo') + streamdetails = SubElement(fileinfo, 'streamdetails') + + # Video data + if data['meta_data'].get('video'): + video = SubElement(streamdetails, 'video') + codec = SubElement(video, 'codec') + codec.text = toUnicode(data['meta_data']['video']) + aspect = SubElement(video, 'aspect') + aspect.text = str(data['meta_data']['aspect']) + width = SubElement(video, 'width') + width.text = str(data['meta_data']['resolution_width']) + height = SubElement(video, 'height') + height.text = str(data['meta_data']['resolution_height']) + + # Audio data + if data['meta_data'].get('audio'): + audio = SubElement(streamdetails, 'audio') + codec = SubElement(audio, 'codec') + codec.text = toUnicode(data['meta_data'].get('audio')) + channels = SubElement(audio, 'channels') + channels.text = toUnicode(data['meta_data'].get('audio_channels')) + # Clean up the xml and return it nfoxml = xml.dom.minidom.parseString(tostring(nfoxml)) xml_string = nfoxml.toprettyxml(indent = ' ') From f0bde7316d4ac9e0b95e18b8617b7d1a608cc98d Mon Sep 17 00:00:00 2001 From: mano3m Date: Fri, 22 Nov 2013 13:07:53 +0100 Subject: [PATCH 6/7] [Metadata][XBMC] Update new actors to actor_roles --- couchpotato/core/providers/info/omdbapi/main.py | 6 +++++- couchpotato/core/providers/info/themoviedb/main.py | 13 ++++++++----- couchpotato/core/providers/metadata/xbmc/main.py | 4 +++- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/couchpotato/core/providers/info/omdbapi/main.py b/couchpotato/core/providers/info/omdbapi/main.py index c5db5ea..605dadf 100755 --- a/couchpotato/core/providers/info/omdbapi/main.py +++ b/couchpotato/core/providers/info/omdbapi/main.py @@ -84,6 +84,10 @@ class OMDBAPI(MovieProvider): year = tryInt(movie.get('Year', '')) + actors = {} + for actor in splitString(movie.get('Actors', '')): + actors[actor] = '' #omdb does not return actor roles + movie_data = { 'type': 'movie', 'via_imdb': True, @@ -105,7 +109,7 @@ class OMDBAPI(MovieProvider): 'genres': splitString(movie.get('Genre', '')), 'directors': splitString(movie.get('Director', '')), 'writers': splitString(movie.get('Writer', '')), - 'actors': [{actor: ''} for actor in splitString(movie.get('Actors', ''))], + 'actor_roles': actors, } movie_data = dict((k, v) for k, v in movie_data.iteritems() if v) except: diff --git a/couchpotato/core/providers/info/themoviedb/main.py b/couchpotato/core/providers/info/themoviedb/main.py index cb44f6d..cd95792 100644 --- a/couchpotato/core/providers/info/themoviedb/main.py +++ b/couchpotato/core/providers/info/themoviedb/main.py @@ -111,10 +111,13 @@ class TheMovieDb(MovieProvider): year = None # Gather actors data - actors = [] + actors = {} for cast_item in movie.cast: - actors.append({toUnicode(cast_item.name): toUnicode(cast_item.character)}) - images.append({'actor %s' % toUnicode(cast_item.name): self.getImage(cast_item, type = 'profile', size = 'original')}) + try: + actors[toUnicode(cast_item.name)] = toUnicode(cast_item.character) + images['actor %s' % toUnicode(cast_item.name)] = self.getImage(cast_item, type = 'profile', size = 'original') + except: + log.debug('Error getting cast info for %s: %s', (cast_item, traceback.format_exc())) movie_data = { 'type': 'movie', @@ -130,7 +133,7 @@ class TheMovieDb(MovieProvider): 'plot': movie.overview, 'genres': genres, 'collection': getattr(movie.collection, 'name', None), - 'actors': actors + 'actor_roles': actors } movie_data = dict((k, v) for k, v in movie_data.iteritems() if v) @@ -154,7 +157,7 @@ class TheMovieDb(MovieProvider): try: image_url = getattr(movie, type).geturl(size = 'original') except: - log.debug('Failed getting %s.%s for "%s"', (type, size, movie.title)) + log.debug('Failed getting %s.%s for "%s"', (type, size, movie)) return image_url diff --git a/couchpotato/core/providers/metadata/xbmc/main.py b/couchpotato/core/providers/metadata/xbmc/main.py index 0d853df..4c547c3 100644 --- a/couchpotato/core/providers/metadata/xbmc/main.py +++ b/couchpotato/core/providers/metadata/xbmc/main.py @@ -89,7 +89,9 @@ class XBMC(MetaDataBase): genres.text = toUnicode(genre) # Actors - for actor_name, role_name in movie_info.get('actors', {}): + for actor_name in movie_info.get('actor_roles', {}): + role_name = movie_info['actor_roles'][actor_name] + actor = SubElement(nfoxml, 'actor') name = SubElement(actor, 'name') name.text = toUnicode(actor_name) From 4553726423913972eed3ed73875ddfe7413367aa Mon Sep 17 00:00:00 2001 From: mano3m Date: Sat, 7 Dec 2013 15:07:41 +0100 Subject: [PATCH 7/7] [Notifications][XBMC] Add always do a full scan option to XBMC Fixes #2498 (at least partially) --- couchpotato/core/notifications/xbmc/__init__.py | 8 ++++++++ couchpotato/core/notifications/xbmc/main.py | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/notifications/xbmc/__init__.py b/couchpotato/core/notifications/xbmc/__init__.py index dafa0f6..04662e2 100644 --- a/couchpotato/core/notifications/xbmc/__init__.py +++ b/couchpotato/core/notifications/xbmc/__init__.py @@ -47,6 +47,14 @@ config = [{ 'description': 'Only scan new movie folder at remote XBMC servers. Works if movie location is the same.', }, { + 'name': 'force_full_scan', + 'label': 'Always do a full scan', + 'default': 0, + 'type': 'bool', + 'advanced': True, + 'description': 'Do a full scan instead of only the new movie. Useful if the XBMC path is different from the path CPS uses.', + }, + { 'name': 'on_snatch', 'default': 0, 'type': 'bool', diff --git a/couchpotato/core/notifications/xbmc/main.py b/couchpotato/core/notifications/xbmc/main.py index dc185c4..9dac497 100755 --- a/couchpotato/core/notifications/xbmc/main.py +++ b/couchpotato/core/notifications/xbmc/main.py @@ -36,7 +36,7 @@ class XBMC(Notification): if data and data.get('destination_dir') and (not self.conf('only_first') or hosts.index(host) == 0): param = {} - if self.conf('remote_dir_scan') or socket.getfqdn('localhost') == socket.getfqdn(host.split(':')[0]): + if not self.conf('force_full_scan') and (self.conf('remote_dir_scan') or socket.getfqdn('localhost') == socket.getfqdn(host.split(':')[0])): param = {'directory': data['destination_dir']} calls.append(('VideoLibrary.Scan', param))