Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def media_listing(media_type):
- log('Using JSON for retrieving info')
- json_query = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.Get%s", "params": {"properties": ["file", "imdbnumber"], "sort": { "method": "label" } }, "id": 1}' % media_type)
- json_response = re.compile( "{(.*?)}", re.DOTALL ).findall(json_query)
- Medialist = []
- ### Search for each item
- for mediaitem in json_response:
- log('Media JSON: %s' %mediaitem)
- findmedianame = re.search( '"label":"(.*?)","', mediaitem )
- if findmedianame:
- medianame = ( findmedianame.group(1) )
- log('Media label: %s' %medianame)
- findpath = re.search( '"file":"(.*?)","', mediaitem )
- if findpath:
- path = (findpath.group(1))
- log('Media path: %s' %path)
- findimdbnumber = re.search( '"imdbnumber":"(.*?)","', mediaitem )
- if findimdbnumber:
- imdbnumber = (findimdbnumber.group(1))
- log('Media imdb: %s' %imdbnumber)
- Media = {}
- Media["name"] = medianame
- Media["id"] = imdbnumber
- Media["path"] = path
- if media_type == 'TVShows':
- findtvshowid = re.search( '"tvshowid":"(.*?)","', mediaitem )
- log('Media ID: %s' %findtvshowid)
- if findtvshowid:
- json_seasonquery = xbmc.executeJSONRPC('{"jsonrpc": "2.0", "method": "VideoLibrary.GetSeasons", "params": {"tvshowid":%s }, "id": 1}' % findtvshowid)
- json_seasonresponse = re.compile( "{(.*?)}", re.DOTALL ).findall(json_seasonquery)
- findseasontotal = re.search( '"total": ?(.*)', json_seasonresponse[0] )
- findseasonstart = re.search( '"total": ?(.*)', json_seasonresponse[0] )
- findseasonend = re.search( '"total": ?(.*)', json_seasonresponse[0] )
- Media["seasontotal"] = (findseasontotal.group(1))
- Media["seasonstart"] = (findseasonstart.group(1))
- Media["seasonend"] = (findseasonend.group(1))
- Medialist.append(Media)
- return Medialist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement