def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        authKey = Prefs["AuthKey"]
        if not server:
            PlexLog.error("Missing server!")
            return

        requestUrl = urljoin(server, "album")
        if authKey:
            requestUrl = requestUrl + "?AuthKey=" + authKey

        PlexLog.debug("Requesting URL: %s" % requestUrl)

        album = request_json(requestUrl, as_album(media))
        if album is None:
            return

        result = MetadataSearchResult(id=media.id,
                                      name=media.title,
                                      lang=lang,
                                      year=None,
                                      score=100)

        results.Append(result)

        PlexLog.debug("===================  Search end  ===================")
    def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        if not server:
            PlexLog.error("Missing server!")
            return

        movie = request_json(urljoin(server, "movie"), as_movie(media))
        if movie is None:
            return

        title = movie.get("title")
        if title is None:
            PlexLog.error("Missing or invalid title: %s" % str(movie))
            return

        aired = convert_date(movie.get("aired"))
        year = aired.year if aired is not None else 0

        # Plex throws exception that have "/" in ID
        mid = create_id(title, year)
        result = MetadataSearchResult(id=mid,
                                      name=title,
                                      year=year,
                                      lang=lang,
                                      score=100)
        results.Append(result)
        PlexLog.debug("===================  Search end  ===================")
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        if not server:
            PlexLog.error("Missing server!")
            return

        show = request_json(urljoin(server, "show"), as_show(media))
        if show is None:
            return
        set_show(metadata, media, show)

        season_summary = show.get("season_summary", {})
        for season in media.seasons:
            season_id = media.seasons[season].id
            summary = season_summary.get(season)
            if summary is not None:
                update_season_summary(season_id, summary)
            for episode in media.seasons[season].episodes:
                episode_metadata = metadata.seasons[season].episodes[episode]
                model = request_json(urljoin(server, "episode"),
                                     as_episode(media, season, episode))
                set_episode(episode_metadata, model)
                set_episode_cover(episode_metadata, media, season, episode)
        PlexLog.debug("===================  Update end  ===================")
Example #4
0
    def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        show = get_show(media)
        if show is None:
            return

        title = show.get("title")
        if title is None:
            PlexLog.error("Missing or invalid title: %s" % str(show))
            return

        aired = convert_date(show.get("aired"))
        year = aired.year if aired is not None else 0

        # Plex throws exception that have "/" in ID
        mid = create_id(title, year)
        result = MetadataSearchResult(id=mid,
                                      name=title,
                                      year=year,
                                      lang=lang,
                                      score=100)
        results.Append(result)
        PlexLog.debug("===================  Search end  ===================")
Example #5
0
def request_json(url, json):
    PlexLog.debug("Request JSON %s" % str(request_json))
    response = requests.post(url, json=json)
    status_code = response.status_code
    if status_code != 200:
        PlexLog.error("HTTP response (%d)" % status_code)
        return None

    try:
        response_json = response.json()
    except ValueError:
        PlexLog.error("Invalid JSON response")
        return None

    PlexLog.debug("Response JSON: %s" % str(response_json))
    return response_json
Example #6
0
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        album = get_album(media)
        if album is None:
            return

        set_album(metadata, media, album)

        PlexLog.debug("===================  Update end  ===================")
    def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        authKey = Prefs["AuthKey"]
        if not server:
            PlexLog.error("Missing server!")
            return

        requestUrl = urljoin(server, "show")
        if authKey:
            requestUrl = requestUrl + "?AuthKey=" + authKey

        PlexLog.debug("Requesting URL: %s" % requestUrl)

        show = request_json(requestUrl, as_show(media))
        if show is None:
            return

        title = show.get("title")
        if title is None:
            PlexLog.error("Missing or invalid title: %s" % str(show))
            return

        aired = convert_date(show.get("aired"))
        year = aired.year if aired is not None else 0

        # Plex throws exception that have "/" in ID
        mid = create_id(title, year)
        result = MetadataSearchResult(id=mid,
                                      name=title,
                                      year=year,
                                      lang=lang,
                                      score=100)
        results.Append(result)
        PlexLog.debug("===================  Search end  ===================")
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        if not server:
            PlexLog.error("Missing server!")
            return

        album = request_json(urljoin(server, "album"), as_album(media))
        if album is None:
            return

        set_album(metadata, media, album)

        PlexLog.debug("===================  Update end  ===================")
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        authKey = Prefs["AuthKey"]
        if not server:
            PlexLog.error("Missing server!")
            return

        requestUrl = urljoin(server, "album")
        if authKey:
            requestUrl = requestUrl + "?AuthKey=" + authKey

        PlexLog.debug("Requesting URL: %s" % requestUrl)

        album = request_json(requestUrl, as_album(media))
        if album is None:
            return

        set_album(metadata, media, album)

        PlexLog.debug("===================  Update end  ===================")
Example #10
0
    def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        album = get_album(media)
        if album is None:
            return

        result = MetadataSearchResult(id=media.id,
                                      name=media.title,
                                      lang=lang,
                                      year=None,
                                      score=100)

        results.Append(result)

        PlexLog.debug("===================  Search end  ===================")
Example #11
0
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        show = get_show_json(media)
        if show is None:
            return

        set_show(metadata, show)

        for season in media.seasons:
            for episode in media.seasons[season].episodes:
                episode_metadata = metadata.seasons[season].episodes[episode]
                model = get_episode_json(media, season, episode)
                if model is not None:
                    set_episode(episode_metadata, model)
                set_episode_cover(episode_metadata, media, season, episode)
        PlexLog.debug("===================  Update end  ===================")
    def search(self, results, media, lang, manual):
        PlexLog.debug("=================== Search Start ===================")
        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        server = Prefs["Server"]
        if not server:
            PlexLog.error("Missing server!")
            return

        artist = request_json(urljoin(server, "artist"), as_artist(media))
        if artist is None:
            return

        result = MetadataSearchResult(id=media.id,
                                      name=media.title,
                                      lang=lang,
                                      year=None,
                                      score=100)

        results.Append(result)

        PlexLog.debug("===================  Search end  ===================")
Example #13
0
    def update(self, metadata, media, lang, force):
        PlexLog.debug("=================== Update Start ===================")

        PlexLog.debug("%s (%s)" % (self.name, self.ver))
        PlexLog.debug("Plex version: %s" % Platform.ServerVersion)

        show = get_show(media)
        if show is None:
            return
        set_show(metadata, media, show)

        season_summary = show.get("season_summary", {})
        for season in media.seasons:
            season_id = media.seasons[season].id
            summary = season_summary.get(int(season))
            if summary is not None:
                update_season_summary(season_id, summary)
            for episode in media.seasons[season].episodes:
                episode_metadata = metadata.seasons[season].episodes[episode]
                model = get_episode(media, season, episode)
                set_episode(episode_metadata, model)
                set_episode_cover(episode_metadata, media, season, episode)
        PlexLog.debug("===================  Update end  ===================")