Ejemplo n.º 1
0
def tmdb_get_metadata(config_path, data, type):
    # Instantiate TMDB objects
    tmdb_id = int(data)

    api_key = config_tools.TMDB(config_path).apikey
    language = config_tools.TMDB(config_path).language
    is_movie = config_tools.Plex(config_path).library_type == "movie"

    if type in ["overview", "poster", "backdrop"]:
        collection = Collection()
        collection.api_key = api_key
        collection.language = language
        try:
            if type == "overview":
                meta = collection.details(tmdb_id).overview
            elif type == "poster":
                meta = collection.details(tmdb_id).poster_path
            elif type == "backdrop":
                meta = collection.details(tmdb_id).backdrop_path
        except AttributeError:
            media = Movie() if is_movie else TV()
            media.api_key = api_key
            media.language = language
            try:
                if type == "overview":
                    meta = media.details(tmdb_id).overview
                elif type == "poster":
                    meta = media.details(tmdb_id).poster_path
                elif type == "backdrop":
                    meta = media.details(tmdb_id).backdrop_path
            except AttributeError:
                raise ValueError(
                    "| TMDb Error: TMBd {} ID: {} not found".format(
                        "Movie/Collection" if is_movie else "Show", tmdb_id))
    elif type in ["biography", "profile", "name"]:
        person = Person()
        person.api_key = api_key
        person.language = language
        try:
            if type == "biography":
                meta = person.details(tmdb_id).biography
            elif type == "profile":
                meta = person.details(tmdb_id).profile_path
            elif type == "name":
                meta = person.details(tmdb_id).name
        except AttributeError:
            raise ValueError(
                "| TMDb Error: TMBd Actor ID: {} not found".format(tmdb_id))
    else:
        raise RuntimeError(
            "type {} not yet supported in tmdb_get_metadata".format(type))

    if meta is None:
        raise ValueError("| TMDb Error: TMDB ID {} has no {}".format(
            tmdb_id, type))
    elif type in ["profile", "poster", "backdrop"]:
        return "https://image.tmdb.org/t/p/original" + meta
    else:
        return meta
def tmdb_get_summary(data, type):
    collection = Collection()
    person = Person()
    collection.api_key = config_tools.TMDB().apikey
    person.api_key = collection.api_key
    collection.language = config_tools.TMDB().language
    person.language = collection.language

    if type == "overview":
        return collection.details(data).overview
    elif type == "biography":
        return person.details(data).biography
def tmdb_get_summary(config_path, data, type):
    # Instantiate TMDB objects
    collection = Collection()
    collection.api_key = config_tools.TMDB(config_path).apikey
    collection.language = config_tools.TMDB(config_path).language
    
    person = Person()
    person.api_key = collection.api_key
    person.language = collection.language

    # Return object based on type
    if type == "overview":          return collection.details(data).overview
    elif type == "biography":       return person.details(data).biography
    elif type == "poster_path":     return collection.details(data).poster_path
    elif type == "profile_path":    return person.details(data).profile_path
    else: raise RuntimeError("type not yet supported in tmdb_get_summary")