def HandleTheMovieDBMovieResult(results): movies = [] log("starting HandleTheMovieDBMovieResult") for movie in results: try: newmovie = { 'Art(fanart)': base_url + fanart_size + str(movie.get('backdrop_path', "")), 'Art(poster)': base_url + poster_size + str(movie.get('poster_path', "")), 'Title': movie.get('title', ""), 'OriginalTitle': movie.get('original_title', ""), 'ID': movie.get('id', ""), 'Path': "", 'Play': "", 'DBID': "", 'Rating': movie.get('vote_average', ""), 'Votes': movie.get('vote_count', ""), 'Year': movie.get('release_date', "")[:4], 'Premiered': movie.get('release_date', "") } if not str(movie['id']) in str(movies): # too dirty movies.append(newmovie) except Exception as e: log("Exception:" + e) prettyprint(movie) movies = CompareWithLibrary(movies) return movies
def HandleTheMovieDBMovieResult(results): movies = [] log("starting HandleTheMovieDBMovieResult") for movie in results: try: newmovie = {'Art(fanart)': base_url + fanart_size + str(movie.get('backdrop_path', "")), 'Art(poster)': base_url + poster_size + str(movie.get('poster_path', "")), 'Title': movie.get('title', ""), 'OriginalTitle': movie.get('original_title', ""), 'ID': movie.get('id', ""), 'Path': "", 'Play': "", 'DBID': "", 'Rating': movie.get('vote_average', ""), 'Votes': movie.get('vote_count', ""), 'Year': movie.get('release_date', "")[:4], 'Premiered': movie.get('release_date', "")} if not str(movie['id']) in str(movies): # too dirty movies.append(newmovie) except Exception as e: log("Exception:" + e) prettyprint(movie) movies = CompareWithLibrary(movies) return movies
def GetExtendedMovieInfo(Id): response = GetMovieDBData("movie/%s?append_to_response=trailers,casts,releases,keywords,similar_movies,lists&language=%s&" % (Id, __addon__.getSetting("LanguageID")),30) prettyprint(response) if True: authors = [] directors = [] genres = [] for item in response['genres']: genres.append(item["name"]) for item in response['casts']['crew']: if item["job"] == "Author": authors.append(item["name"]) if item["job"] == "Director": directors.append(item["name"]) Writer = " / ".join(authors) Director = " / ".join(directors) Genre = " / ".join(genres) if len(response['trailers']['youtube']) > 0: Trailer = response['trailers']['youtube'][0]['source'] else: Trailer = "" if len(response['releases']['countries']) > 0: mpaa = response['releases']['countries'][0]['certification'] else: mpaa = "" if len(response['production_countries']) > 0: Country = response['production_countries'][0]["name"] else: Country = "" if len(response['production_companies']) > 0: Studio = response['production_companies'][0]["name"] else: Studio = "" Set = response.get("belongs_to_collection","") if Set: SetName = Set.get("name","") SetID = Set.get("id","") else: SetName = "" SetID = "" if 'release_date' in response and response.get('release_date') <> None: year = response.get('release_date',"")[:4] else: year = "" BudgetValue = response.get('budget',"") if not BudgetValue in [0,""]: Budget = millify(float(BudgetValue)) else: Budget = "" newmovie = {'Art(fanart)': base_url + fanart_size + str(response.get('backdrop_path',"")), 'Fanart': base_url + fanart_size + str(response.get('backdrop_path',"")), 'Art(poster)': base_url + poster_size + str(response.get('poster_path',"")), 'Poster': base_url + poster_size + str(response.get('poster_path',"")), 'Title': response.get('title',""), 'Label': response.get('title',""), 'Tagline': response.get('tagline',""), 'RunningTime': response.get('runtime',""), 'Budget': response.get('budget',""), 'mpaa': mpaa, 'Director': Director, 'Writer': Writer, 'Budget': Budget, 'Homepage': response.get('homepage',""), 'Set': SetName, 'SetId': SetID, 'ID': response.get('id',""), 'Plot': response.get('overview',""), 'OriginalTitle': response.get('original_title',""), 'Genre': Genre, 'Rating': response.get('vote_average',""), 'Play': '', 'Trailer': 'plugin://plugin.video.youtube/?action=play_video&videoid=%s' %Trailer, 'ReleaseDate':response.get('release_date',""), 'Premiered':response.get('release_date',""), 'Country':Country, 'Studio':Studio, 'DiscArt':"", 'VideoResolution':"", 'AudioChannels':"", 'VideoCodec':"", 'VideoAspect':"", 'Logo': "", 'DBID': "", 'Studio':Studio, 'Year': year } else: return False newmovie = CompareWithLibrary([newmovie]) return newmovie[0]
def GetExtendedMovieInfo(Id): response = GetMovieDBData( "movie/%s?append_to_response=trailers,casts,releases,keywords,similar_movies,lists&language=%s&" % (Id, __addon__.getSetting("LanguageID")), 30, ) prettyprint(response) if True: authors = [] directors = [] genres = [] for item in response["genres"]: genres.append(item["name"]) for item in response["casts"]["crew"]: if item["job"] == "Author": authors.append(item["name"]) if item["job"] == "Director": directors.append(item["name"]) Writer = " / ".join(authors) Director = " / ".join(directors) Genre = " / ".join(genres) if len(response["trailers"]["youtube"]) > 0: Trailer = response["trailers"]["youtube"][0]["source"] else: Trailer = "" if len(response["releases"]["countries"]) > 0: mpaa = response["releases"]["countries"][0]["certification"] else: mpaa = "" if len(response["production_countries"]) > 0: Country = response["production_countries"][0]["name"] else: Country = "" if len(response["production_companies"]) > 0: Studio = response["production_companies"][0]["name"] else: Studio = "" Set = response.get("belongs_to_collection", "") if Set: SetName = Set.get("name", "") SetID = Set.get("id", "") else: SetName = "" SetID = "" if "release_date" in response and response.get("release_date") <> None: year = response.get("release_date", "")[:4] else: year = "" BudgetValue = response.get("budget", "") if not BudgetValue in [0, ""]: Budget = millify(float(BudgetValue)) else: Budget = "" newmovie = { "Art(fanart)": base_url + fanart_size + str(response.get("backdrop_path", "")), "Fanart": base_url + fanart_size + str(response.get("backdrop_path", "")), "Art(poster)": base_url + poster_size + str(response.get("poster_path", "")), "Poster": base_url + poster_size + str(response.get("poster_path", "")), "Title": response.get("title", ""), "Label": response.get("title", ""), "Tagline": response.get("tagline", ""), "RunningTime": response.get("runtime", ""), "Budget": response.get("budget", ""), "mpaa": mpaa, "Director": Director, "Writer": Writer, "Budget": Budget, "Homepage": response.get("homepage", ""), "Set": SetName, "SetId": SetID, "ID": response.get("id", ""), "Plot": response.get("overview", ""), "OriginalTitle": response.get("original_title", ""), "Genre": Genre, "Rating": response.get("vote_average", ""), "Play": "", "Trailer": "plugin://plugin.video.youtube/?action=play_video&videoid=%s" % Trailer, "ReleaseDate": response.get("release_date", ""), "Premiered": response.get("release_date", ""), "Country": Country, "Studio": Studio, "DiscArt": "", "VideoResolution": "", "AudioChannels": "", "VideoCodec": "", "VideoAspect": "", "Logo": "", "DBID": "", "Studio": Studio, "Year": year, } else: return False newmovie = CompareWithLibrary([newmovie]) return newmovie[0]
def _StartInfoActions(self): if not self.silent: xbmc.executebuiltin( "ActivateWindow(busydialog)" ) for info in self.infos: if info == 'json': from MiscScraper import GetYoutubeVideos videos = GetYoutubeVideos(self.feed,self.prop_prefix) passDataToSkin('RSS', videos, self.prop_prefix) elif info == 'similarlocal' and self.dbid: passDataToSkin('SimilarLocalMovies', None , self.prop_prefix) from Utils import GetSimilarFromOwnLibrary passDataToSkin('SimilarLocalMovies', GetSimilarFromOwnLibrary(self.dbid) , self.prop_prefix) elif info == 'xkcd': log("startin GetXKCDInfo") from MiscScraper import GetXKCDInfo passDataToSkin('XKCD', GetXKCDInfo(), self.prop_prefix) elif info == 'flickr': from MiscScraper import GetFlickrImages log("startin flickr") passDataToSkin('Flickr', GetFlickrImages(), self.prop_prefix) elif info == 'discography': passDataToSkin('Discography', None, self.prop_prefix) log("startin gettopalbums") from OnlineMusicInfo import GetArtistTopAlbums passDataToSkin('Discography', GetArtistTopAlbums(self.Artist_mbid), self.prop_prefix) elif info == 'artistdetails': passDataToSkin('Discography', None, self.prop_prefix) passDataToSkin('MusicVideos', None, self.prop_prefix) log("startin ArtistDetails") from TheAudioDB import GetDiscography, GetArtistDetails, GetMostLovedTracks, GetMusicVideos ArtistDetails = GetArtistDetails(self.ArtistName) MusicVideos = GetMusicVideos(ArtistDetails["audiodbid"]) # GetAudioDBData("search.php?s=Blur") GetMostLovedTracks(self.ArtistName) passDataToSkin('MusicVideos', MusicVideos, self.prop_prefix) # from TheAudioDB import GetArtistTopAlbums passDataToSkin('Discography', GetDiscography(self.ArtistName), self.prop_prefix) passHomeDataToSkin(ArtistDetails) elif info == 'albuminfo': passHomeDataToSkin(None) log("startin ArtistDetails") from TheAudioDB import GetAlbumDetails, GetTrackDetails if self.id: AlbumDetails = GetAlbumDetails(self.id) Trackinfo = GetTrackDetails(self.id) prettyprint(AlbumDetails) passHomeDataToSkin(AlbumDetails) passDataToSkin('Trackinfo', Trackinfo, self.prop_prefix) elif info == 'shouts': log("startin shouts") passDataToSkin('Shout', None, self.prop_prefix) from OnlineMusicInfo import GetShouts passDataToSkin('Shout', GetShouts(self.ArtistName,self.AlbumName), self.prop_prefix,True) elif info == 'studio': passDataToSkin('StudioInfo', None, self.prop_prefix) if self.studio: log("startin companyinfo") from TheMovieDB import SearchforCompany, GetCompanyInfo CompanyId = SearchforCompany(self.studio) passDataToSkin('StudioInfo', GetCompanyInfo(CompanyId), self.prop_prefix) elif info == 'set': passDataToSkin('MovieSetItems', None, self.prop_prefix) if self.dbid and not "show" in str(self.type): from TheMovieDB import SearchForSet from Utils import GetMovieSetName name = GetMovieSetName(self.dbid) if name: log(name) self.setid = SearchForSet(name) log("yyyy") log(self.setid) if self.setid: log("startin SetInfo") from TheMovieDB import GetSetMovies SetData = GetSetMovies(self.setid) if SetData: passDataToSkin('MovieSetItems', SetData, self.prop_prefix) elif info == 'topartists': passDataToSkin('TopArtists', None, self.prop_prefix) log("startin gettopartists") from OnlineMusicInfo import GetTopArtists passDataToSkin('TopArtists', GetTopArtists(), self.prop_prefix) elif info == 'cyanide': log("startin GetCandHInfo") from MiscScraper import GetCandHInfo passDataToSkin('CyanideHappiness', GetCandHInfo(), self.prop_prefix) elif info == 'incinemaRT': log("start gettin InCinema info") from MiscScraper import GetRottenTomatoesMovies passDataToSkin('InCinemaMovies', GetRottenTomatoesMovies("in_theaters"), self.prop_prefix) elif info == 'boxoffice': log("start gettin boxoffice info") from MiscScraper import GetRottenTomatoesMovies passDataToSkin('BoxOffice', GetRottenTomatoesMovies("box_office"), self.prop_prefix) elif info == 'opening': log("start gettin opening info") from MiscScraper import GetRottenTomatoesMovies passDataToSkin('Opening', GetRottenTomatoesMovies("opening"), self.prop_prefix) elif info == 'upcoming': log("start gettin upcoming info") # from MiscScraper import GetRottenTomatoesMovies # passDataToSkin('UpcomingMovies', GetRottenTomatoesMovies("upcoming"), self.prop_prefix, True) from TheMovieDB import GetMovieDBMovies passDataToSkin('UpcomingMovies', GetMovieDBMovies("upcoming"), self.prop_prefix) elif info == 'incinema': log("start gettin InCinemaMovies info") from TheMovieDB import GetMovieDBMovies passDataToSkin('InCinemaMovies', GetMovieDBMovies("now_playing"), self.prop_prefix) elif info == 'popular': log("start gettin popularmovies info") from TheMovieDB import GetMovieDBMovies passDataToSkin('PopularMovies', GetMovieDBMovies("popular"), self.prop_prefix) elif info == 'toprated': log("start gettin InCinemaMovies info") from TheMovieDB import GetMovieDBMovies passDataToSkin('TopRatedMovies', GetMovieDBMovies("top_rated"), self.prop_prefix) elif info == 'toprentals': log("start gettin toprentals info") from MiscScraper import GetRottenTomatoesMovies passDataToSkin('TopRentals', GetRottenTomatoesMovies("top_rentals"), self.prop_prefix) elif info == 'similarmovies': log("startin MovieDBGetSimilarMovies") passDataToSkin('SimilarMovies', None, self.prop_prefix) from TheMovieDB import GetSimilarMovies # MovieId = GetDatabaseID(self.id) if self.id: MovieId = self.id elif self.dbid: MovieId = GetDatabaseID("movie",self.dbid) log("IMDBId from local DB:" + str(MovieId)) else: MovieId = "" if MovieId: passDataToSkin('SimilarMovies', GetSimilarMovies(MovieId), self.prop_prefix) elif info == 'movielists': passDataToSkin('MovieLists', None, self.prop_prefix) if self.dbid: log("startin movielists") from TheMovieDB import GetMovieLists id = GetDatabaseID("movie",self.dbid) log("MovieDB Id:" + str(id)) if id: passDataToSkin('MovieLists', GetMovieLists(id), self.prop_prefix) elif info == 'keywords': passDataToSkin('Keywords', None, self.prop_prefix) if self.dbid: log("startin Keywords") from TheMovieDB import GetMovieKeywords id = GetDatabaseID("movie",self.dbid) log("MovieDB Id:" + str(id)) if id: passDataToSkin('Keywords', GetMovieKeywords(id), self.prop_prefix) elif info == 'extendedinfo': log("startin GetExtendedMovieInfo") if self.id: MovieId = self.id elif self.dbid: MovieId = GetDatabaseID("movie",self.dbid) log("IMDBId from local DB:" + str(MovieId)) else: MovieId = "" if MovieId: from TheMovieDB import GetExtendedMovieInfo passHomeDataToSkin(GetExtendedMovieInfo(MovieId)) elif info == 'extendedtvinfo': if self.id: log("startin GetTVShowInfo") from MiscScraper import GetTVShowInfo passHomeDataToSkin(GetTVShowInfo(self.id)[0]) elif info == 'directormovies': passDataToSkin('DirectorMovies', None, self.prop_prefix) if self.director: log("startin GetDirectorMovies") from TheMovieDB import GetDirectorMovies, GetPersonID id = GetPersonID(self.director) if id: passDataToSkin('DirectorMovies', GetDirectorMovies(id), self.prop_prefix) elif info == 'writermovies': passDataToSkin('WriterMovies', None, self.prop_prefix) if self.writer and not self.writer.split(" / ")[0] == self.director.split(" / ")[0]: log("startin GetWriterMovies") from TheMovieDB import GetDirectorMovies, GetPersonID id = GetPersonID(self.writer) if id: passDataToSkin('WriterMovies', GetDirectorMovies(id), self.prop_prefix) elif info == 'similar': passDataToSkin('SimilarMovies', None, self.prop_prefix) log("startin GetSimilarTrakt") log(self.dbid) log(self.id) log(self.type) from MiscScraper import GetSimilarTrakt if self.type and (self.id or self.dbid): if self.dbid: id = GetDatabaseID(self.type,self.dbid) log("SimilarTrakt: found dbid " + str(id)) else: id = self.id passDataToSkin('SimilarMovies', GetSimilarTrakt(self.type,id), self.prop_prefix) elif info == 'airingshows': log("startin GetTraktCalendarShows") from MiscScraper import GetTraktCalendarShows passDataToSkin('AiringShows', GetTraktCalendarShows("shows"), self.prop_prefix) elif info == 'premiereshows': log("startin GetTraktCalendarShows") from MiscScraper import GetTraktCalendarShows passDataToSkin('PremiereShows', GetTraktCalendarShows("premieres"), self.prop_prefix) elif info == 'trendingshows': log("startin GetTrendingShows") from MiscScraper import GetTrendingShows passDataToSkin('TrendingShows', GetTrendingShows(), self.prop_prefix) elif info == 'trendingmovies': log("startin GetTrendingMovies") from MiscScraper import GetTrendingMovies passDataToSkin('TrendingMovies', GetTrendingMovies(), self.prop_prefix) elif info == 'similarartistsinlibrary': from Utils import GetSimilarArtistsInLibrary passDataToSkin('SimilarArtistsInLibrary', None, self.prop_prefix) passDataToSkin('SimilarArtists', GetSimilarArtistsInLibrary(self.Artist_mbid), self.prop_prefix) elif info == 'artistevents': passDataToSkin('ArtistEvents', None, self.prop_prefix) from OnlineMusicInfo import GetEvents # events = GetEvents(self.Artist_mbid) passDataToSkin('ArtistEvents', GetEvents(self.Artist_mbid), self.prop_prefix) elif info == 'youtubesearch': passDataToSkin('YoutubeSearch', None, self.prop_prefix) from MiscScraper import GetYoutubeSearchVideos # events = GetEvents(self.Artist_mbid) passDataToSkin('YoutubeSearch', GetYoutubeSearchVideos(self.id,self.hd,self.orderby,self.time), self.prop_prefix) elif info == 'youtubeusersearch': passDataToSkin('YoutubeUserSearch', None, self.prop_prefix) from MiscScraper import GetYoutubeUserVideos passDataToSkin('YoutubeUserSearch', GetYoutubeUserVideos(self.id), self.prop_prefix,True) elif info == 'nearevents': passDataToSkin('NearEvents', None, self.prop_prefix) from OnlineMusicInfo import GetNearEvents passDataToSkin('NearEvents', GetNearEvents(self.tag,self.festivalsonly), self.prop_prefix) elif info == 'venueevents': passDataToSkin('VenueEvents', None, self.prop_prefix) from OnlineMusicInfo import GetVenueEvents passDataToSkin('VenueEvents', GetVenueEvents(self.id), self.prop_prefix) elif info == 'topartistsnearevents': from Utils import GetXBMCArtists from OnlineMusicInfo import GetArtistNearEvents passDataToSkin('TopArtistsNearEvents', None, self.prop_prefix) artists = GetXBMCArtists() events = GetArtistNearEvents(artists["result"]["artists"][0:15]) passDataToSkin('TopArtistsNearEvents', events, self.prop_prefix) elif info == 'updatexbmcdatabasewithartistmbidbg': from MusicBrainz import SetMusicBrainzIDsForAllArtists SetMusicBrainzIDsForAllArtists(False, 'forceupdate' in AdditionalParams) elif info == 'updatexbmcdatabasewithartistmbid': from MusicBrainz import SetMusicBrainzIDsForAllArtists SetMusicBrainzIDsForAllArtists(True, 'forceupdate' in AdditionalParams) elif info == 'getlocationevents': from OnlineMusicInfo import GetNearEvents wnd = xbmcgui.Window(Window) lat = wnd.getProperty('%slat' % self.prop_prefix) lon = wnd.getProperty('%slon' % self.prop_prefix) passDataToSkin('NearEvents', GetNearEvents(self.tag,self.festivalsonly,lat,lon), self.prop_prefix) elif info == 'getgooglemap' or info == 'getgooglestreetviewmap': direction = "" from MiscScraper import GetGoogleMap, GetGeoCodes, string2deg wnd = xbmcgui.Window(Window) if self.location == "geocode": # convert Image Coordinates to float values self.lat = string2deg(self.lat) self.lon = string2deg(self.lon) log(self.lat) log(self.lon) if info == 'getgooglemap': # request normal map image = GetGoogleMap(mode = "normal",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = self.direction) overview = "" else: # request streetview direction = str(int(self.direction) * 18) image = GetGoogleMap(mode = "streetview",search_string = self.location,aspect = self.aspect,type = self.type, lat = self.lat,lon = self.lon,zoomlevel = self.zoomlevel,direction = direction) overview = GetGoogleMap(mode = "normal",search_string = self.location,aspect = self.aspect,type = "roadmap", lat = self.lat,lon = self.lon,zoomlevel = "17",direction = direction) wnd.setProperty('%sgooglemap' % self.prop_prefix, image) # set properties wnd.setProperty('%sgooglemapoverview' % self.prop_prefix, overview) wnd.setProperty('%sDirection' % self.prop_prefix, str(self.direction)) wnd.setProperty('%sDirection2' % self.prop_prefix, str(direction)) if not self.lat or self.location=="geocode": # set properties for lat / lon (after JSON call for speed) lat = self.lat lon = self.lon if not self.location=="geocode": lat, lon = GetGeoCodes(self.location) wnd.setProperty('%slat' % self.prop_prefix, str(lat)) wnd.setProperty('%slon' % self.prop_prefix, str(lon)) wnd.setProperty('%sLocation' % self.prop_prefix, "") elif "move" in info and "google" in info: from MiscScraper import GetGoogleMap wnd = xbmcgui.Window(Window) lat = wnd.getProperty('%slat' % self.prop_prefix) lon = wnd.getProperty('%slon' % self.prop_prefix) direction = int(self.direction) * 18 if lat and lon: if "street" in info: from math import sin, cos, radians stepsize = 0.0002 radiantdirection = radians(float(direction)) if "up" in info: lat = float(lat) + cos(radiantdirection) * stepsize lon = float(lon) + sin(radiantdirection) * stepsize elif "down" in info: lat = float(lat) - cos(radiantdirection) * stepsize lon = float(lon) - sin(radiantdirection) * stepsize elif "left" in info: lat = float(lat) - sin(radiantdirection) * stepsize lon = float(lon) - cos(radiantdirection) * stepsize elif "right" in info: lat = float(lat) + sin(radiantdirection) * stepsize lon = float(lon) + cos(radiantdirection) * stepsize else: stepsize = 200.0 / float(self.zoomlevel) / float(self.zoomlevel) / float(self.zoomlevel) / float(self.zoomlevel) if "up" in info: lat = float(lat) + stepsize elif "down" in info: lat = float(lat) - stepsize elif "left" in info: lon = float(lon) - 2.0 * stepsize elif "right" in info: lon = float(lon) + 2.0 * stepsize self.location = str(lat) + "," + str(lon) if "street" in info: image = GetGoogleMap(mode = "streetview",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = direction) overview = GetGoogleMap(mode = "normal",search_string = self.location,aspect = self.aspect,type = "roadmap", lat = self.lat,lon = self.lon,zoomlevel = "17",direction = self.direction) else: image = GetGoogleMap(mode = "normal",search_string = self.location,zoomlevel = self.zoomlevel,type = self.type,aspect = self.aspect, lat=self.lat,lon=self.lon,direction = self.direction) overview = "" wnd.setProperty('%sgooglemap' % self.prop_prefix, image) wnd.setProperty('%sgooglemapoverview' % self.prop_prefix, overview) wnd.setProperty('%slat' % self.prop_prefix, str(lat)) wnd.setProperty('%sDirection' % self.prop_prefix, self.direction) wnd.setProperty('%slon' % self.prop_prefix, str(lon)) if not self.silent: xbmc.executebuiltin( "Dialog.Close(busydialog)" )