Giter VIP home page Giter VIP logo

script.module.metadatautils's Introduction

script.module.metadatautils

Codacy Badge

Kodi python module to retrieve rich artwork and metadata for common kodi media items The module is integrated with the simplecache module so that information is properly cached

This product uses the TMDb API but is not endorsed or certified by TMDb.

For the retrieval of metadata several API's are used (like omdbapi, fanart.tv tmdb) The requests to these api's are rate-limited and cached by this addon to not overload those free, great services. The addon settings will contain options for users to enter their personal/payed API-key to enable all features of the API and remove the rate limiter.

Help needed with maintaining !

I am very busy currently so I do not have a lot of time to work on this project or watch the forums. Be aware that this is a community driven project, so feel free to submit PR's yourself to improve the code and/or help others with support on the forums etc. If you're willing to really participate in the development, please contact me so I can give you write access to the repo. I do my best to maintain the project every once in a while, when I have some spare time left. Thanks for understanding!

Usage

You can use this python library as module within your own Kodi scripts/addons. Just make sure to import it within your addon.xml:

<requires>
    <import addon="script.module.metadatautils" version="1.0.0" />
</requires>

Now, to use it in your Kodi addon/script, make sure to import it and you can access it's methods.

from metadatautils import MetadataUtils
metadatautils = MetadataUtils()

#do your stuff here, like like calling any of the available methods

NOTE: make sure to use unnamed arguments for all methods to not confuse the cache e.g. metadatautils.use get_tvdb_details("", "12345") instead of metadatautils.use get_tvdb_details(tvdb_id="12345")


API Keys

The module contains some default api keys to get you started quickly but be aware, these api keys are heavily rate limited (and use a very long cache expiration) There will be a warning printed in the log for each time a call is made with a rate limited api key consider them as for testing purposes only and respect the metadata websites providing the info. There are 2 ways to override the default, rate limited api keys:

  1. User/Personal api keys. A user can set his own, personal api key in the Kodi addon settings for the module.

  2. API key for your application You can set your own api key(s) when initializing the class:

mutils = MetadataUtils()
mutils.omdb.api_key = 'YOUR API KEY FOR OMDB API'
mutils.tmdb.api_key = 'YOUR API KEY FOR TMDB'
mutils.fanarttv.api_key = 'YOUR API KEY FOR FANART.TV'
mutils.thetvdb.api_key = 'YOUR API KEY FOR TheTvdb'
mutils.lastfm.api_key = 'YOUR API KEY FOR LastFM'
mutils.audiodb.api_key = 'YOUR API KEY FOR The Audio DB'

Available methods

get_extrafanart(file_path, media_type)

    retrieve the extrafanart path for a kodi media item
    Parameters: 
    file_path: the full filepath (ListItem.FileNameAndPath) for the media item
    media_type: The container content type e.g. movies/tvshows/episodes/musicvideos/seasons

get_music_artwork(self, artist, album="", track="", disc="")

    get music artwork for the given artist/album/song
    Parameters: 
    artist: the name of the artist (required)
    album: name of the album (optional, result will include album details if provided)
    track: name of the track (optional, result will include album details if provided)
    disc: discnumber of the track (optional)
    the more parameters supplied, the more accurate the results will be.
    
    Note: In the addon settings for the kodi module, the user can set personal preferences for the scraper.

music_artwork_options(self, artist, album="", track="", disc="")

    Shows a dialog to manually override the artwork by the user for the given media
    Parameters: 
    artist: the name of the artist (required)
    album: name of the album (optional, result will include album details if provided)
    track: name of the track (optional, result will include album details if provided)
    disc: discnumber of the track (optional)

get_extended_artwork(imdb_id="", tvdb_id="", media_type="")

    Returns all available artwork from fanart.tv for the kodi video
    Parameters: 
    imdb_id: imdbid of the media
    tvdb_id: tvdbid of the media (can be used instead of imdbid, one of them is required)
    media_type: The container content type --> movies or tvshows
    in case of episodes or seasons, provide the tvshow details

get_tmdb_details(imdb_id="", tvdb_id="", title="", year="", media_type="", manual_select=False)

    Returns the complete (kodi compatible formatted) metadata from TMDB
    Parameters: 
    imdb_id: imdbid of the media (strict match if submitted)
    tvdb_id: tvdbid of the media (strict match if submitted)
    title: title of the media if no imdbid/tvdbid is present (search)
    year: year of the media (for more accurate search results if title supplied)
    media_type: The container content type (movies or tvshows) - for more accurate search results if searching by title
    manual_select: will show a select dialog to choose the preferred result (if searching by title)
    
    By default, the search by title will return the most likely result. It is suggested to also submit the year and/or media type for better matching

get_moviesetdetails(set_id)

    Returns complete (nicely formatted) information about the movieset and it's movies
    Parameters: 
    set_id: Kodi DBID for the movieset (str/int)

get_streamdetails(db_id, media_type)

    Returns complete (nicely formatted) streamdetails (resolutions, audiostreams etc.) for the kodi media item
    Parameters: 
    db_id: Kodi DBID for the item (str/int)
    media_type: movies/episodes/musicvideos

get_pvr_artwork(title, channel="", genre="", manual_select=False)

    Returns complete (nicely formatted) metadata including artwork for the given pvr broadcast.
    Uses numerous searches to get the info. Result is localized whenever possible.
    Parameters: 
    title: The title of the PVR entry (required)
    channel: the channelname of the PVR entry (optional, for better matching)
    genre: the genre of the PVR entry (optional, for better matching)
    manual_select: will show a select dialog to choose the preferred result
    
    Note: In the addon settings for the kodi module, the user can set personal preferences for the scraper.

pvr_artwork_options(title, channel="", genre="")

    Shows a dialog to manually override/scrape the artwork by the user for the given PVR entry (used for example in contextmenu)
    Parameters: 
    title: The title of the PVR entry (required)
    channel: the channelname of the PVR entry (optional, for better matching)
    genre: the genre of the PVR entry (optional, for better matching)

get_channellogo(channelname)

    Returns the channellogo (if found) for the given channel name.
    Looks up kodi PVR addon first, and fallsback to the logo db.

get_studio_logo(studio)

    Returns the studio logo for the given studio (searches the artwork paths to find the correct logo)
    Input may be a single studio as string, multiple studios as string or even a list of studios.
    The logos path/resource addon is scanned untill a logo is found for any of the supplied studios.
    
    NOTE: Requires a searchpath to be set, see method below!

studiologos_path(filepath)

    Sets/gets the path to look for studio logos, used in above "get_studio_logo" method.
    this can be a path on the filesystem, VFS path or path to a resource addon:
    _metadatautils.studiologos_path("my_path_to_the_studio_logos")
    Can also be used as getter if no value supplied.

get_animated_artwork(imdb_id, manual_select=False)

    Get animated artwork (poster and/or fanart) if exists for the given movie by querying the consiliumdb with animatedart.
    For more info, see: http://forum.kodi.tv/showthread.php?tid=215727
    
    Parameters: 
    imdb_id: IMDBID of the movie (may also be TMDBID)
    manual_select: (optional) if True a dialog will be shown to the user to select the preferred result.
    
    NOTE: After scraping the artwork is also stored in the kodi db so it can be accessed by Listitem.Art(animatedposter) and Listitem.Art(animatedfanart)

get_omdb_info(imdb_id="", title="", year="", content_type="")

    Get (kodi compatible formatted) metadata from OMDB, including Rotten tomatoes details
    
    Parameters: 
    imdb_id: IMDBID of the movie/tvshow
    title: Title of the movie/tvshow (if imdbid ommitted)
    year: Year of the movie/tvshow (for better search results when searching by title)
    media_type: Mediatype movies/tvshows (for better search results when searching by title)

get_top250_rating(imdb_id)

    get the position in the IMDB top250 for the given IMDB ID (tvshow or movie)

get_tvdb_details(imdbid="", tvdbid="")

    gets all information for the given tvshow from TVDB, including details of the next airing episode, the last aired episoded and air date and time.
    Input is either the imdbid or the tvdbid.

script.module.metadatautils's People

Contributors

angelinas1 avatar anontester avatar codacy-badger avatar djdirty60 avatar dmyoung9 avatar eng2heb avatar guilouz avatar im85288 avatar iz8mbw avatar marcelveldt avatar natevoci avatar razzeee avatar viper67857 avatar wsx79 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

script.module.metadatautils's Issues

Duration : Changes to skinning engine kodi krypton to leia

Hi, since there is a change that duration can use time format strings in leia

$INFO[ListItem.Duration(hh,, h] $INFO[ListItem.Duration(mm,, min]
or $INFO[ListItem.Duration(h,, h] $INFO[ListItem.Duration(m,, min]
or $INFO[ListItem.Duration]

SO Thats just working correct in krypton, but get issues in leia.
ALSO its not needed in leia anymore,because you can use kodi labels to seperate durstion types (hh: mm) or (mins) possible in leia to

def get_duration(duration):

'''transform duration time in minutes to hours:minutes'''
if not duration:
    return {}
if isinstance(duration, (unicode, str)):
    duration.replace("min", "").replace("", "").replace(".", "")
try:
    total_minutes = int(duration)
    if total_minutes < 60:
        hours = 0
    else:
        hours = total_minutes / 60
    minutes = total_minutes - (hours * 60)
    formatted_time = "%s:%s" % (hours, str(minutes).zfill(2))
except Exception as exc:
    log_exception(__name__, exc)
    return {}
return {
    "Duration": formatted_time,
    "Duration.Hours": hours,
    "Duration.Minutes": minutes,
    "Runtime": total_minutes,
    "RuntimeExtended": "%s %s" % (total_minutes, xbmc.getLocalizedString(12391)),
    "DurationAndRuntime": "%s (%s min.)" % (formatted_time, total_minutes),
    "DurationAndRuntimeExtended": "%s (%s %s)" % (formatted_time, total_minutes, xbmc.getLocalizedString(12391))
}

Failed to install a dependancy

Hi there I'm getting failed to install when trying to install the metadata and artwork module on nexus, can anyone help

Bypassing omdb calls

Hi Marcel,

Is there are way to set in any settings file that you want to bypass calls to omdb?

My log is full of these messages because I don't have (or want) to "buy" a key:

01:22:42.342 T:1237316592 NOTICE: script.module.metadatautils --> Rate limiter active for omdbapi.com - delaying request with 2 seconds - Configure a personal API key in the settings to get rid of this message and the delay.

I am using the Eminence 2 MOD skin, that uses skin.helper.service and script.module.metadatautils.

Or could I just delete the omdb.py file in the script.module.metadatautils/lib/helpers folder? :)

ps Sorry for asking here, but the official Kodi forum is already down for 6+ days...

Error in 'helpers.utils'

ERROR: script.module.metadatautils --> ERROR in helpers.utils ! --> ('Connection aborted.', BadStatusLine("''",))
WARNING: script.module.metadatautils --> Traceback (most recent call last):

File "/storage/.kodi/addons/script.module.metadatautils/lib/helpers/utils.py", line 114, in get_json
  response = requests.get(url, params=params, timeout=20)

File "/storage/.kodi/addons/script.module.requests/lib/requests/api.py", line 72, in get
  return request('get', url, params=params, **kwargs)

File "/storage/.kodi/addons/script.module.requests/lib/requests/api.py", line 58, in request
  return session.request(method=method, url=url, **kwargs)

File "/storage/.kodi/addons/script.module.requests/lib/requests/sessions.py", line 512, in request
 resp = self.send(prep, **send_kwargs)

File "/storage/.kodi/addons/script.module.requests/lib/requests/sessions.py", line 622, in send
  r = adapter.send(request, **kwargs)

File "/storage/.kodi/addons/script.module.requests/lib/requests/adapters.py", line 495, in send
  raise ConnectionError(err, request=request)

ConnectionError: ('Connection aborted.', BadStatusLine("''",))

ERROR: script.module.metadatautils --> ERROR in helpers.utils ! --> ('Connection aborted.',   BadStatusLine("''",))

String for webservice type=discart is empty

Marcel AnimatedArt working but need to add this two line in kodidb.py
Now with code http://localhost:52307/getartwork&amp;title=$INFO[Window.Property(Title)]&amp;type=discart Art doesent excist......
ERROR: CCurlFile::Stat - Failed: Timeout was reached(28) for http://localhost:52307/getartwork&title=Logan&type=discart
add this please ROW 665 IN kodidb.py

            if art.get("discart"):
                art["discart"] = get_clean_image(art["discart"])
            if art.get("clearart"):
                art["clearart"] = get_clean_image(art["clearart"])

Fichier 'Favourites.xml' sur disque réseau

Bonjour,

J'utilise SkinHelperService pour créer un widget Favoris mais cela ne fonctionne pas.

J'utilise un "paste substitute" dans mon fichier advancedsetting.xml dans userdata car mon fichier "favorites.xml" est sur mon réseau SMB.

Y a t-il un moyen de faire fonctionner le widget car il ne fonctionne qu'avec le fichier favoris en local dans userdata.

Merci pour votre aide.

downloading gifs to script.module.metadatautils

hi ,
it keeps downloading gifs to the folder .kodi\userdata\addon_data\script.module.metadatautils\ even though i disabled gifs downloading in my skin (EMINENCE 2 MOD (REVIVED)) , the thing is that this folder getting "heavy" because some gifs are even 10 MB....
thanks..

[Bug] CPU Load rises to 100%, Network traffic also rises

Hello,

I am using Krypton 17.6 together with the Titan skin and after the upgrade to version 1.0.19 of the Metadata and Artwork addon, the CPU load rises up to 100%, the htpc receives data from the NAS with nearly 70 Mbit/s and the fan is going mad. This behaviour continues even when being in idle state, for example in the main menu of Kodi without playing any media.
(EDIT: I am sure, that this addon must be the reason for this behaviour because I coincidentally created an image of the whole system one week ago. Within this week just 5 addons got an update and as soon as I install the upgrade of metadatautils this behaviour occurs)

https://imgur.com/loIRMvI
https://imgur.com/S1WDhi1

Log: https://pastebin.com/SZ0UQT9u

this will not install in kodi 19

> <import addon="script.module.thetvdb" version="0.0.1" />

the updated version has not been added to marcels repo

and

> <import addon="script.module.beautifulsoup" version="3.0.8" />

can not be found , obviously bs4 is been updated and added to repo , but not 1 , i dont' know if with the latest fix's its even needed.

Running into dep hell trying to work on porting a skin from kodi 18 to 19 .

Thanks

Script.Module.Metadatautils incompatibility with Kodi Leia/18

I figured it was finally time to migrate from Krypton to Leia but Titan was a base requirement for me. Unfortunately none of the current mods seemed to have fixed a problem with 'Skin Helper Widgets' for Music. Many of them don't work -- for me it was a desire for the 'Random Albums' widget that drove me to finally investigate.

The fix is pretty simple (for me at least).

Change this line in the script.module.metadatautils\lib\kodi-constants.py from

FIELDS_ALBUMS = ["title", "fanart", "thumbnail", "genre", "displayartist", "artist", "genreid",
"musicbrainzalbumartistid", "year", "rating", "artistid", "musicbrainzalbumid", "theme", "description",
"type", "style", "playcount", "albumlabel", "mood", "dateadded"]

to

FIELDS_ALBUMS = ["title", "fanart", "thumbnail", "genre", "displayartist", "artist",
"musicbrainzalbumartistid", "year", "rating", "artistid", "musicbrainzalbumid", "theme", "description",
"type", "style", "playcount", "albumlabel", "mood", "dateadded"]

Note: Kodi 18 JSON API no longer supports the parameter "genreid" for the GetAlbums method for the AudioLibrary (class).

I thought that I'd mention this (rudimentary) fix for the mod authors (or any one else interested) who might be able to include it in their repositories. (In retrospect, after I had tracked this down, I see that a user 'Angelinas1' has already noted this fix in github -- that would have saved me some time!)

cheers,
Lee

Fanart.tv problems

In this days there a lot of problems with Fanart.tv scrapers, due site problems. The result is a lot of missing images. This is what I receive on the LOG:
https://paste.kodi.tv/izeqinifox.kodi

So, it's possibile to completely disable scrapers on PVR from Fanart.tv, and leave only TVDB and TMDB? I tray to remove Fanart.tv API key from settings, but it doesn't work.

Where to best put personal keys

Hi Marcel,

Up until now I just put my personal keys in the .py modules, but you state you can also put them in the settings.xml:

https://github.com/marcelveldt/script.module.metadatautils

1. User/Personal api keys. A user can set his own, personal api key in the Kodi addon settings for the module.

The settings.xml file does not exist in

osmc\.kodi\userdata\addon_data\script.module.metadatautils\

so I've created one manually with this content:

<settings>
     <setting id="fanarttv_apikey" value="keyvaluehere"/>
     <setting id="omdbapi_apikey" value="keyvaluehere"/>
     <setting id="tmdb_apikey" value="keyvaluehere"/>       
</settings>

but that doesn't seem to work.

What is the best way to configure the keys?

Greetings,

Hablaras

Fix so works with all numeric AudioDB API keys

I'm in the US and have a all numeric AudioDB API key. In order for things to work I need to change a line in lib, helpers, theaudiodb.py and replace the existing code in the line near end of py file with -

endpoint = 'https://www.theaudiodb.com/api/v1/json/%s/%s' % (self.api_key, endpoint)

Is it possible to change the code so that it works no matter what type of AudioDB API key is used so that the manual change is no longer needed? Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.