示例#1
0
def get_installed_resources():
    global search_path
    import os
    main = kodi.vfs.join(os.path.dirname(os.path.abspath(__file__)),
                         'scrapers')
    results = [{
        'path': main,
        'name': 'ScrapeCore',
        'addonid': 'script.module.scrapecore'
    }]
    test_path = kodi.vfs.join(kodi.get_path(), 'resources/scrapers/')
    if kodi.vfs.exists(test_path):
        results += [{
            'path': kodi.vfs.join(kodi.get_path(), 'resources'),
            'name': kodi.get_name(),
            'addonid': kodi.get_id()
        }]

    temp = kodi.kodi_json_request(
        "Addons.GetAddons", {
            "installed": True,
            'type': 'kodi.resource.images',
            "properties": ["path", "name"]
        })
    for a in temp['result']['addons']:
        if a['type'] == 'kodi.resource.images' and a['addonid'].startswith(
                'resource.scrapecore.'):
            del a['type']
            results.append(a)
    return results
示例#2
0
def master_control():
    options = [
        "Send to Master Control", "Stream with Master Control",
        "Master Control Queue"
    ]
    c = kodi.dialog_select("Master Control Menu", options)
    if c is False: return
    if c == 2:
        kodi.execute_url("plugin://master.control?mode=queue")
    elif c == 1:
        from scrapecore import scrapers
        resolved_url = scrapers.get_scraper_by_name(
            kodi.args['service']).resolve_url(kodi.args['raw_url'])
        if not resolved_url: return
        from mastercontrol import api as master_control
        stream_url = master_control.get_streaming_url(resolved_url)
        kodi.play_url(stream_url)
    elif c == 0:
        ids = kodi.arg('ids', decode='json')
        from commoncore import trakt
        from mastercontrol import api as master_control
        if kodi.args['media'] == 'movie':
            media = 'movie'
            title = "%s (%s)" % (kodi.args['title'], kodi.args['year'])
            filename = kodi.vfs.clean_file_name(title)
            destination = ''
        else:
            media = 'tvshow'
            destination = kodi.vfs.join(kodi.args['title'],
                                        "Season %s" % kodi.args['season'])
            title = "%s - S%02dE%02d" % (kodi.args['title'],
                                         int(kodi.args['season']),
                                         int(kodi.args['episode']))
            filename = kodi.vfs.clean_file_name(title)

        from scrapecore import scrapers
        resolved_url = scrapers.get_scraper_by_name(
            kodi.args['service']).resolve_url(kodi.args['raw_url'])
        if not resolved_url: return
        video = {
            "type": media,
            "filename": filename,
            "url": resolved_url,
            "title": title,
            "addon": kodi.get_id(),
            "destination": destination,
            "trakt_id": kodi.args['trakt_id']
        }
        response = master_control.enqueue(video)
        kodi.log(response)
        message = 'Failed Adding to Queue %s.' % (title)
        try:
            if response['status'] == 200:
                message = 'Added to Queue %s.' % (title)
        except:
            pass
        kodi.notify(kodi.get_name(), message)
 def update(self):
     if enable_updates:
         if not self.last_run or time.time(
         ) - self.last_run > self.update_interval:
             self.last_run = time.time()
             plugin_url = kodi.build_plugin_url(
                 {
                     "mode": "update_addons",
                     "quiet": "quiet"
                 }, kodi.get_id())
             kodi.execute_url(plugin_url)