Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Commit

Permalink
Make compatible with Plex Premium agent
Browse files Browse the repository at this point in the history
  • Loading branch information
piplongrun authored Mar 4, 2017
1 parent 80d533e commit 8177b59
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions Contents/Code/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unicodedata

VERSION = '1.0.2'
VERSION = '2.0'
SERACH_URL = 'https://tadata.me/muvio/?artist=%s'

TYPE_ORDER = ['music_video', 'live_music', 'lyric_video']
Expand Down Expand Up @@ -43,12 +43,12 @@ class Muvio(Agent.Artist):
name = 'MUVIO'
languages = [Locale.Language.NoLanguage]
primary_provider = False
contributes_to = ['com.plexapp.agents.lastfm']
contributes_to = ['com.plexapp.agents.lastfm', 'com.plexapp.agents.plexmusic']

def search(self, results, media, lang):
def search(self, results, media, lang, manual=False, tree=None):

results.Append(MetadataSearchResult(
id = ArtistName(media.primary_metadata.title),
results.add(SearchResult(
id = ArtistName(tree.title),
score = 100
))

Expand All @@ -60,6 +60,9 @@ def update(self, metadata, media, lang):
Log('*** Call to search API failed... ***')
return None

if not 'videos' in json_obj:
return None

extras = []

for video in json_obj['videos']:
Expand Down Expand Up @@ -91,22 +94,12 @@ class Muvio(Agent.Album):
name = 'MUVIO'
languages = [Locale.Language.NoLanguage]
primary_provider = False
contributes_to = ['com.plexapp.agents.lastfm']

def search(self, results, media, lang):
contributes_to = ['com.plexapp.agents.lastfm', 'com.plexapp.agents.plexmusic']

artist = ArtistName(String.Unquote(media.primary_metadata.id.split('/')[0])) # Album object doesn't have artist information(?). Grab it from the metadata id instead.
def search(self, results, media, lang, manual=False, tree=None):

try:
json_obj = JSON.ObjectFromURL(SERACH_URL % (String.Quote(artist)))
except:
Log('*** Call to search API failed... ***')
return None

artist = json_obj['artist']

results.Append(MetadataSearchResult(
id = artist,
results.add(SearchResult(
id = ArtistName(tree.title),
score = 100
))

Expand All @@ -117,6 +110,9 @@ def update(self, metadata, media, lang):
except:
return None

if not 'videos' in json_obj:
return None

for index, track in enumerate(media.children):

for video in json_obj['videos']:
Expand Down

0 comments on commit 8177b59

Please sign in to comment.