Пример #1
0
def add_group(type, **kwargs):
    type = str(type)

    groups = load_file(type + '_groups.json', ext=False, isJSON=True)

    if not groups:
        groups = []
    else:
        groups = list(groups)

    name = gui.input(message=_.ADD_GROUP, default='').strip()

    if name and len(str(name)) > 0 and name != str(type).lower():
        groups.append(name)
        groups = sorted(groups)
        write_file(type + '_groups.json', data=groups, ext=False, isJSON=True)

        method = 'GUI.ActivateWindow'
        json_rpc(
            method, {
                "window":
                "videos",
                "parameters":
                ["plugin://" + ADDON_ID + "/?_=groups_menu&type=" + type]
            })
Пример #2
0
def _restore_network_bandwidth(**kwargs):
    bandwidth = load_file('bandwidth', isJSON=False)

    if bandwidth:
        method = 'settings.SetSettingValue'
        json_rpc(method, {
            "setting": "network.bandwidth",
            "value": "{}".format(bandwidth)
        })

    try:
        os.remove(os.path.join(ADDON_PROFILE, 'bandwidth'))
    except:
        pass

    bandwidth2 = load_file('bandwidth2', isJSON=False)

    if bandwidth2:
        try:
            xbmcaddon.Addon('inputstream.ffmpegdirect').setSetting(
                'streamBandwidth', str(bandwidth2))
        except:
            pass

    try:
        os.remove(os.path.join(ADDON_PROFILE, 'bandwidth2'))
    except:
        pass
Пример #3
0
def change_group(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

    id = str(id)
    type_tv_radio = str(type_tv_radio)

    select_list = []

    if type_tv_radio == 'radio':
        groups = load_file('radio_groups.json', ext=False, isJSON=True)
        typestr = 'Radio'
    else:
        groups = load_file('tv_groups.json', ext=False, isJSON=True)
        typestr = 'TV'

    select_list.append(typestr)

    for group in groups:
        select_list.append(group)

    selected = gui.select(_.SELECT_GROUP, select_list)

    if type_tv_radio == 'radio':
        prefs = load_radio_prefs(profile_id=1)
    else:
        prefs = load_prefs(profile_id=1)

    try:
        prefs[id]['group'] = select_list[selected]
    except:
        pass

    if type_tv_radio == 'radio':
        save_radio_prefs(profile_id=1, prefs=prefs)
    else:
        save_prefs(profile_id=1, prefs=prefs)

    method = 'GUI.ActivateWindow'
    json_rpc(
        method, {
            "window":
            "videos",
            "parameters": [
                'plugin://' + str(ADDON_ID) +
                '/?_=group_picker_menu&type_tv_radio=' + type_tv_radio
            ]
        })
Пример #4
0
def change_order(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

    if type_tv_radio == 'live':
        order = load_order(profile_id=1)
    else:
        order = load_radio_order(profile_id=1)

    id = str(id)
    type_tv_radio = str(type_tv_radio)

    selected = gui.numeric(_.SELECT_ORDER, order[id])
    double = None
    double_query = ''

    if selected and selected >= 0:
        for currow in order:
            if id == str(currow):
                continue

            if int(order[currow]) == int(selected):
                double = currow
                break

        order[id] = selected

    if type_tv_radio == 'live':
        save_order(profile_id=1, order=order)
    else:
        save_radio_order(profile_id=1, order=order)

    if double:
        double_query = '&double={double}&primary={primary}'.format(
            double=double, primary=id)

    method = 'GUI.ActivateWindow'
    json_rpc(
        method, {
            "window":
            "videos",
            "parameters": [
                'plugin://' + str(ADDON_ID) + '/?_=order_picker_menu' +
                double_query + '&type_tv_radio=' + type_tv_radio
            ]
        })
Пример #5
0
def finish_setup(setup=0, **kwargs):
    setup = int(setup)

    api_get_all_epg()

    create_playlist()
    create_epg()

    method = 'Addons.SetAddonEnabled'
    json_rpc(method, {"addonid": "pvr.iptvsimple", "enabled": "false"})
    xbmc.sleep(2000)
    json_rpc(method, {"addonid": "pvr.iptvsimple", "enabled": "true"})

    if setup == 1:
        setup_iptv()

    xbmc.executebuiltin('Dialog.Close(busydialog)')
    xbmc.executebuiltin('ActivateWindow(%d)' % 10000)
Пример #6
0
def _reset(**kwargs):
    if not gui.yes_no(_.PLUGIN_RESET_YES_NO):
        return

    _close()

    try:
        method = 'Addons.SetAddonEnabled'
        json_rpc(method, {"addonid": ADDON_ID, "enabled": "false"})

        remove_dir(directory="cache", ext=False)
        remove_dir(directory="tmp", ext=False)

        for file in glob.glob(os.path.join(ADDON_PROFILE, "stream*")):
            remove_file(file=file, ext=True)

        for file in glob.glob(os.path.join(ADDON_PROFILE, "*.json")):
            remove_file(file=file, ext=True)

        for file in glob.glob(os.path.join(ADDON_PROFILE, "*.xml")):
            remove_file(file=file, ext=True)

        if not os.path.isdir(os.path.join(ADDON_PROFILE, "cache")):
            os.makedirs(os.path.join(ADDON_PROFILE, "cache"))

        if not os.path.isdir(os.path.join(ADDON_PROFILE, "tmp")):
            os.makedirs(os.path.join(ADDON_PROFILE, "tmp"))

        if not os.path.isdir(os.path.join(ADDON_PROFILE, "movies")):
            os.makedirs(os.path.join(ADDON_PROFILE, "movies"))

        if not os.path.isdir(os.path.join(ADDON_PROFILE, "shows")):
            os.makedirs(os.path.join(ADDON_PROFILE, "shows"))
    except:
        pass

    method = 'Addons.SetAddonEnabled'
    json_rpc(method, {"addonid": ADDON_ID, "enabled": "true"})

    gui.notification(_.PLUGIN_RESET_OK)
    signals.emit(signals.AFTER_RESET)
    gui.refresh()
Пример #7
0
def _set_network_bandwidth(**kwargs):
    method = 'settings.GetSettingValue'
    cursetting = json_rpc(method, {"setting": "network.bandwidth"})

    if not cursetting['value'] == int(settings.getInt(key='max_bandwidth')):
        method = 'settings.SetSettingValue'
        json_rpc(
            method, {
                "setting": "network.bandwidth",
                "value": "{}".format(settings.getInt(key='max_bandwidth'))
            })
        write_file('bandwidth', data=cursetting['value'], isJSON=False)

    try:
        cursetting = xbmcaddon.Addon('inputstream.ffmpegdirect').getSetting(
            'streamBandwidth')

        if not int(cursetting) == int(settings.getInt(key='max_bandwidth')):
            xbmcaddon.Addon('inputstream.ffmpegdirect').setSetting(
                'streamBandwidth', str(settings.getInt(key='max_bandwidth')))
            write_file('bandwidth2', data=cursetting, isJSON=False)
    except:
        pass
Пример #8
0
def remove_group(type, name, **kwargs):
    type = str(type)

    if not gui.yes_no(_.REMOVE_GROUP + '?'):
        return

    groups = load_file(type + '_groups.json', ext=False, isJSON=True)

    if not groups:
        groups = []
    else:
        groups = list(groups)

    groups.remove(name)

    write_file(type + '_groups.json', data=groups, ext=False, isJSON=True)

    method = 'GUI.ActivateWindow'
    json_rpc(
        method, {
            "window": "videos",
            "parameters":
            ["plugin://" + ADDON_ID + "/?_=groups_menu&type=" + type]
        })
Пример #9
0
def change_channel(id, type_tv_radio, **kwargs):
    if not id or len(str(id)) == 0:
        return False

    id = str(id)
    type_tv_radio = str(type_tv_radio)

    if type_tv_radio == 'radio':
        prefs = load_radio_prefs(profile_id=1)

        mod_pref = prefs[id]

        if int(mod_pref['radio']) == 0:
            mod_pref['radio'] = 1
        else:
            mod_pref['radio'] = 0

        prefs[id] = mod_pref
        save_radio_prefs(profile_id=1, prefs=prefs)

        method = 'GUI.ActivateWindow'
        json_rpc(
            method, {
                "window":
                "videos",
                "parameters": [
                    'plugin://' + str(ADDON_ID) +
                    '/?_=channel_picker_menu&type_tv_radio=radio&save_all=0'
                ]
            })
    else:
        profile_settings = load_profile(profile_id=1)
        prefs = load_prefs(profile_id=1)
        all_channels = load_channels(type='all')
        type_tv_radio = str(type_tv_radio)

        select_list = []
        num = 0

        for x in range(1, 6):
            if len(profile_settings['addon' + str(x)]) > 0:
                video_addon = profile_settings['addon' + str(x)]

                type_channels = load_channels(
                    type=video_addon.replace('plugin.video.', ''))

                VIDEO_ADDON_PROFILE = ADDON_PROFILE.replace(
                    ADDON_ID, video_addon)
                addon_prefs = load_file(VIDEO_ADDON_PROFILE + 'prefs.json',
                                        ext=True,
                                        isJSON=True)

                row2 = all_channels[id]

                type_id = str(row2[video_addon + '_id'])

                if len(type_id) > 0:
                    row = type_channels[type_id]

                    disabled = False

                    if addon_prefs:
                        try:
                            if check_key(addon_prefs, str(row['id'])) and int(
                                    addon_prefs[str(
                                        row['id'])][type_tv_radio]) == 0:
                                disabled = True
                        except:
                            pass

                    if disabled == False:
                        select_list.append(
                            profile_settings['addon' + str(x)].replace(
                                'plugin.video.', ''))
                        num += 1

        select_list.append(_.DISABLED)

        selected = gui.select(_.SELECT_ADDON, select_list)
        mod_pref = prefs[id]

        if selected and selected >= 0:
            mod_pref[type_tv_radio + '_auto'] = 0

            if selected == num:
                mod_pref[type_tv_radio] = 0
                mod_pref[type_tv_radio + '_addonid'] = ''
                mod_pref[type_tv_radio + '_channelid'] = ''
                mod_pref[type_tv_radio + '_channelassetid'] = ''

                if type_tv_radio == 'live':
                    mod_pref['channelname'] = ''
                    mod_pref['channelicon'] = ''
            else:
                mod_pref[type_tv_radio] = 1
                mod_pref[type_tv_radio +
                         '_addonid'] = 'plugin.video.' + select_list[selected]
                mod_pref[type_tv_radio + '_channelid'] = ''
                mod_pref[type_tv_radio + '_channelassetid'] = ''
                if type_tv_radio == 'live':
                    mod_pref['channelname'] = ''
                    mod_pref['channelicon'] = ''

                type_channels = load_channels(type=select_list[selected])
                row2 = all_channels[id]

                type_id = str(row2[mod_pref[type_tv_radio + '_addonid'] +
                                   '_id'])

                if len(type_id) > 0:
                    row = type_channels[type_id]

                    mod_pref[type_tv_radio + '_channelid'] = row['id']
                    mod_pref[type_tv_radio +
                             '_channelassetid'] = row['assetid']

                    if type_tv_radio == 'live':
                        mod_pref['channelname'] = row['name']
                        mod_pref['channelicon'] = row['icon']

            prefs[id] = mod_pref
            save_prefs(profile_id=1, prefs=prefs)

        method = 'GUI.ActivateWindow'
        json_rpc(
            method, {
                "window":
                "videos",
                "parameters": [
                    'plugin://' + str(ADDON_ID) +
                    '/?_=channel_picker_menu&type_tv_radio=' + type_tv_radio +
                    '&save_all=0'
                ]
            })
Пример #10
0
def setup_iptv():
    try:
        IPTV_SIMPLE_ADDON_ID = "pvr.iptvsimple"

        try:
            IPTV_SIMPLE = xbmcaddon.Addon(id=IPTV_SIMPLE_ADDON_ID)
        except:
            xbmc.executebuiltin(
                'InstallAddon({})'.format(IPTV_SIMPLE_ADDON_ID), True)

            try:
                IPTV_SIMPLE = xbmcaddon.Addon(id=IPTV_SIMPLE_ADDON_ID)
            except:
                pass

        if IPTV_SIMPLE.getSettingBool("epgCache") != True:
            IPTV_SIMPLE.setSettingBool("epgCache", True)

        if IPTV_SIMPLE.getSettingInt("epgPathType") != 0:
            IPTV_SIMPLE.setSettingInt("epgPathType", 0)

        if IPTV_SIMPLE.getSetting("epgPath") != ADDON_PROFILE + "epg.xml":
            IPTV_SIMPLE.setSetting("epgPath", ADDON_PROFILE + "epg.xml")

        if IPTV_SIMPLE.getSetting("epgTimeShift") != "0":
            IPTV_SIMPLE.setSetting("epgTimeShift", "0")

        if IPTV_SIMPLE.getSettingBool("epgTSOverride") != False:
            IPTV_SIMPLE.setSettingBool("epgTSOverride", False)

        try:
            if IPTV_SIMPLE.getSettingBool("catchupEnabled") != True:
                IPTV_SIMPLE.setSettingBool("catchupEnabled", True)

            if IPTV_SIMPLE.getSetting("catchupQueryFormat") != "":
                IPTV_SIMPLE.setSetting("catchupQueryFormat", "")

            if IPTV_SIMPLE.getSettingInt("catchupDays") != 7:
                IPTV_SIMPLE.setSettingInt("catchupDays", 7)

            if IPTV_SIMPLE.getSettingInt("allChannelsCatchupMode") != 0:
                IPTV_SIMPLE.setSettingInt("allChannelsCatchupMode", 0)

            if IPTV_SIMPLE.getSettingBool("catchupPlayEpgAsLive") != False:
                IPTV_SIMPLE.setSettingBool("catchupPlayEpgAsLive", False)

            if IPTV_SIMPLE.getSettingInt(
                    "catchupWatchEpgBeginBufferMins") != 5:
                IPTV_SIMPLE.setSettingInt("catchupWatchEpgBeginBufferMins", 5)

            if IPTV_SIMPLE.getSettingInt("catchupWatchEpgEndBufferMins") != 15:
                IPTV_SIMPLE.setSettingInt("catchupWatchEpgEndBufferMins", 15)

            if IPTV_SIMPLE.getSettingBool(
                    "catchupOnlyOnFinishedProgrammes") != True:
                IPTV_SIMPLE.setSettingBool("catchupOnlyOnFinishedProgrammes",
                                           True)

            if IPTV_SIMPLE.getSettingBool("timeshiftEnabled") != False:
                IPTV_SIMPLE.setSettingBool("timeshiftEnabled", False)
        except:
            pass

        if IPTV_SIMPLE.getSettingBool("m3uCache") != True:
            IPTV_SIMPLE.setSettingBool("m3uCache", True)

        if IPTV_SIMPLE.getSettingInt("m3uPathType") != 0:
            IPTV_SIMPLE.setSettingInt("m3uPathType", 0)

        if IPTV_SIMPLE.getSetting(
                "m3uPath") != ADDON_PROFILE + "playlist.m3u8":
            IPTV_SIMPLE.setSetting("m3uPath", ADDON_PROFILE + "playlist.m3u8")

        if IPTV_SIMPLE.getSettingInt("startNum") != 1:
            IPTV_SIMPLE.setSettingInt("startNum", 1)

        if IPTV_SIMPLE.getSettingBool("numberByOrder") != False:
            IPTV_SIMPLE.setSettingBool("numberByOrder", False)

        if IPTV_SIMPLE.getSettingInt("m3uRefreshMode") != 1:
            IPTV_SIMPLE.setSettingInt("m3uRefreshMode", 1)

        if IPTV_SIMPLE.getSettingInt("m3uRefreshIntervalMins") != 120:
            IPTV_SIMPLE.setSettingInt("m3uRefreshIntervalMins", 120)

        if IPTV_SIMPLE.getSettingInt("m3uRefreshHour") != 4:
            IPTV_SIMPLE.setSettingInt("m3uRefreshHour", 4)

        method = 'Addons.SetAddonEnabled'
        json_rpc(method, {"addonid": "pvr.iptvsimple", "enabled": "false"})
        xbmc.sleep(2000)
        json_rpc(method, {"addonid": "pvr.iptvsimple", "enabled": "true"})
    except:
        pass
Пример #11
0
    def play(self):
        try:
            if 'seekTime' in self.properties or sys.argv[3] == 'resume:true':
                self.properties.pop('ResumeTime', None)
                self.properties.pop('TotalTime', None)
        except:
            pass

        device_id = plugin_get_device_id

        if not device_id:
            method = 'settings.GetSettingValue'
            cursetting = {}
            cursetting['debug.extralogging'] = json_rpc(
                method, {"setting": "debug.extralogging"})['value']
            cursetting['debug.showloginfo'] = json_rpc(
                method, {"setting": "debug.showloginfo"})['value']
            cursetting['debug.setextraloglevel'] = json_rpc(
                method, {"setting": "debug.setextraloglevel"})['value']

            method = 'settings.SetSettingValue'
            json_rpc(method, {
                "setting": "debug.extralogging",
                "value": "true"
            })
            json_rpc(method, {"setting": "debug.showloginfo", "value": "true"})
            json_rpc(method, {
                "setting": "debug.setextraloglevel",
                "value": [64]
            })

        if settings.getBool(key='disable_subtitle'):
            self.properties['disable_subtitle'] = 1

        li = self.get_li()
        handle = _handle()

        #if 'seekTime' in self.properties:
        #li.setProperty('ResumeTime', str(self.properties['seekTime']))

        #if 'totalTime' in self.properties:
        #    li.setProperty('TotalTime', str(self.properties['totalTime']))
        #else:
        #    li.setProperty('TotalTime', '999999')

        player = MyPlayer()

        playbackStarted = False
        seekTime = False
        replay_pvr = False

        if handle > 0:
            if 'Replay' in self.properties or 'PVR' in self.properties:
                replay_pvr = True
                self.properties.pop('Replay', None)
                self.properties.pop('PVR', None)
                xbmcplugin.setResolvedUrl(handle, True, li)
            else:
                xbmcplugin.setResolvedUrl(handle, False, li)
                player.play(self.path, li)
        else:
            player.play(self.path, li)

        currentTime = 0
        upnext = settings.getBool('upnext_enabled')

        while player.is_active:
            if xbmc.getCondVisibility("Player.HasMedia") and player.is_started:
                if playbackStarted == False:
                    playbackStarted = True

                if upnext:
                    upnext = False
                    result = json_rpc("XBMC.GetInfoLabels", {
                        "labels":
                        ["VideoPlayer.DBID", "VideoPlayer.TvShowDBID"]
                    })

                    if result and len(str(
                            result['VideoPlayer.DBID'])) > 0 and len(
                                str(result['VideoPlayer.TvShowDBID'])) > 0:
                        result2 = json_rpc(
                            "VideoLibrary.GetEpisodes", {
                                "tvshowid":
                                int(result['VideoPlayer.TvShowDBID']),
                                "properties": [
                                    "title", "plot", "rating", "firstaired",
                                    "playcount", "runtime", "season",
                                    "episode", "showtitle", "fanart",
                                    "thumbnail", "art"
                                ]
                            })
                        nextep = 0
                        current_episode = dict()
                        next_episode = dict()

                        if result2:
                            for result3 in result2['episodes']:
                                if nextep == 0 and int(
                                        result3['episodeid']) == int(
                                            result['VideoPlayer.DBID']):
                                    current_episode = dict(
                                        episodeid=result3['episodeid'],
                                        tvshowid=int(
                                            result['VideoPlayer.TvShowDBID']),
                                        title=result3["title"],
                                        art=result3["art"],
                                        season=result3["season"],
                                        episode=result3["episode"],
                                        showtitle=result3["showtitle"],
                                        plot=result3["plot"],
                                        playcount=result3["playcount"],
                                        rating=result3["rating"],
                                        firstaired=result3["firstaired"],
                                        runtime=result3["runtime"])

                                    nextep = 1
                                elif nextep == 1:
                                    params = []
                                    params.append(('_', 'play_dbitem'))
                                    params.append(('id', result3['episodeid']))

                                    path = 'plugin://{0}/?{1}'.format(
                                        ADDON_ID,
                                        urlencode(encode_obj(params)))

                                    next_info = dict(
                                        current_episode=current_episode,
                                        next_episode=dict(
                                            episodeid=result3['episodeid'],
                                            tvshowid=int(result[
                                                'VideoPlayer.TvShowDBID']),
                                            title=result3["title"],
                                            art=result3["art"],
                                            season=result3["season"],
                                            episode=result3["episode"],
                                            showtitle=result3["showtitle"],
                                            plot=result3["plot"],
                                            playcount=result3["playcount"],
                                            rating=result3["rating"],
                                            firstaired=result3["firstaired"],
                                            runtime=result3["runtime"]),
                                        play_url=path,
                                        #notification_time=60,
                                        #notification_offset=notification_offset,
                                    )

                                    upnext_signal(sender=ADDON_ID,
                                                  next_info=next_info)
                                    #upnext_signal(sender=ADDON_ID)
                                    break

                if not device_id:
                    player.stop()

                if 'disable_subtitle' in self.properties:
                    player.showSubtitles(False)
                    self.properties.pop('disable_subtitle', None)

                if 'seekTime' in self.properties:
                    seekTime = True
                    xbmc.Monitor().waitForAbort(1)
                    player.seekTime(int(self.properties['seekTime']))
                    self.properties.pop('seekTime', None)

                if not replay_pvr and not seekTime and 'Live' in self.properties and 'Live_ID' in self.properties and 'Live_Channel' in self.properties:
                    id = self.properties['Live_ID']
                    channel = self.properties['Live_Channel']

                    self.properties.pop('Live', None)
                    self.properties.pop('Live_ID', None)
                    self.properties.pop('Live_Channel', None)

                    wait = 60

                    end = load_file(file='stream_end', isJSON=False)

                    if end:
                        calc_wait = int(end) - int(time.time()) + 30

                        if calc_wait > 60:
                            wait = calc_wait

                    while not xbmc.Monitor().waitForAbort(
                            wait) and xbmc.getCondVisibility(
                                "Player.HasMedia") and player.is_started:
                        info = None

                        try:
                            info = api_get_info(id=id, channel=channel)
                        except:
                            pass

                        if info:
                            info2 = {
                                'plot': str(info['description']),
                                'title': str(info['label1']),
                                'tagline': str(info['label2']),
                                'duration': info['duration'],
                                'credits': info['credits'],
                                'cast': info['cast'],
                                'director': info['director'],
                                'writer': info['writer'],
                                'genre': info['genres'],
                                'year': info['year'],
                            }

                            li.setInfo('video', info2)

                            li.setArt({
                                'thumb': info['image'],
                                'icon': info['image'],
                                'fanart': info['image_large']
                            })

                            try:
                                player.updateInfoTag(li)
                            except:
                                pass

                            wait = 60
                            end = load_file(file='stream_end', isJSON=False)

                            if end:
                                calc_wait = int(end) - int(time.time()) + 30

                                if calc_wait > 60:
                                    wait = calc_wait

            xbmc.Monitor().waitForAbort(1)

            try:
                currentTime = player.getTime()
            except:
                pass

        if playbackStarted == True:
            api_clean_after_playback(int(currentTime))

            try:
                if settings.getInt(key='max_bandwidth') > 0:
                    _restore_network_bandwidth()
            except:
                pass

        if not device_id:
            json_rpc(
                method, {
                    "setting": "debug.showloginfo",
                    "value": cursetting['debug.showloginfo']
                })
            json_rpc(
                method, {
                    "setting":
                    "debug.setextraloglevel",
                    "value":
                    str(', '.join([
                        str(elem)
                        for elem in cursetting['debug.setextraloglevel']
                    ]))
                })
            json_rpc(
                method, {
                    "setting": "debug.extralogging",
                    "value": cursetting['debug.setextraloglevel']
                })
Пример #12
0
def _set_settings_kodi(**kwargs):
    _close()

    try:
        method = 'settings.SetSettingValue'

        json_rpc(method, {
            "setting": "videoplayer.preferdefaultflag",
            "value": "true"
        })
        json_rpc(method, {
            "setting": "videoplayer.preferdefaultflag",
            "value": "true"
        })
        json_rpc(method, {
            "setting": "locale.audiolanguage",
            "value": "default"
        })
        json_rpc(method, {
            "setting": "locale.subtitlelanguage",
            "value": "default"
        })
        json_rpc(method, {
            "setting": "pvrmanager.preselectplayingchannel",
            "value": "false"
        })
        json_rpc(method, {
            "setting": "pvrmanager.syncchannelgroups",
            "value": "true"
        })
        json_rpc(method, {
            "setting": "pvrmanager.backendchannelorder",
            "value": "true"
        })
        json_rpc(method, {
            "setting": "pvrmanager.usebackendchannelnumbers",
            "value": "true"
        })
        json_rpc(method, {"setting": "epg.selectaction", "value": 5})
        json_rpc(method, {"setting": "epg.pastdaystodisplay", "value": 7})
        json_rpc(method, {"setting": "epg.futuredaystodisplay", "value": 1})
        json_rpc(method, {
            "setting": "epg.hidenoinfoavailable",
            "value": "true"
        })
        json_rpc(method, {"setting": "epg.epgupdate", "value": 720})
        json_rpc(method, {
            "setting": "epg.preventupdateswhileplayingtv",
            "value": "true"
        })
        json_rpc(method, {"setting": "epg.ignoredbforclient", "value": "true"})
        json_rpc(method, {
            "setting": "pvrrecord.instantrecordaction",
            "value": 2
        })
        json_rpc(method, {
            "setting": "pvrpowermanagement.enabled",
            "value": "false"
        })
        json_rpc(method, {"setting": "pvrparental.enabled", "value": "false"})

        gui.notification(_.DONE_NOREBOOT)
    except:
        pass
Пример #13
0
def create_nfo_file(filename, data, type):
    doc = Document()

    if type == 'movie':
        root = doc.createElement("movie")
    elif type == 'show':
        root = doc.createElement("tvshow")
    else:
        root = doc.createElement("episodedetails")

        if len(str(data['title'])) == 0:
            data['title'] = 'Aflevering {episode}'.format(
                episode=data['position'])

    doc.appendChild(root)

    XMLvalues = {}
    XMLvalues['title'] = str(data['title'])

    if len(str(data['description'])) > 0:
        XMLvalues['plot'] = str(data['description'])

    if not type == 'show' and len(str(data['duration'])) > 0 and int(
            data['duration']) > 0:
        XMLvalues['runtime'] = str(int(int(data['duration']) / 60))

    if len(str(data['datum'])) > 3:
        XMLvalues['year'] = str(data['datum'])[:4]

    for value in XMLvalues:
        tempChild = doc.createElement(value)
        root.appendChild(tempChild)
        nodeText = doc.createTextNode(XMLvalues[value].strip())
        tempChild.appendChild(nodeText)

    tempChild = doc.createElement('uniqueid')
    tempChild.setAttribute("type", str(PROVIDER_NAME))
    tempChild.setAttribute("default", 'true')
    root.appendChild(tempChild)
    nodeText = doc.createTextNode(str(data['id']).strip())
    tempChild.appendChild(nodeText)

    if not type == 'episode':
        if type == 'show':
            genres = data['category']
        else:
            genres = data['category'].split(', ')

        if len(genres) > 0:
            for genre in genres:
                tempChild = doc.createElement('genre')
                root.appendChild(tempChild)
                nodeText = doc.createTextNode(str(genre).strip())
                tempChild.appendChild(nodeText)

    if check_key(data, 'seasons'):
        for season in data['seasons']:
            origtitle = data['seasons'][season]
            tempChild = doc.createElement('namedseason')

            if str(origtitle).strip().isnumeric():
                nodeText = doc.createTextNode('Seizoen ' +
                                              str(origtitle).strip())
            else:
                nodeText = doc.createTextNode(str(origtitle).strip())

            tempChild.appendChild(nodeText)
            tempChild.setAttribute("number", season)
            root.appendChild(tempChild)

    tempChild = doc.createElement('thumb')

    if type == 'movie' or type == 'show':
        tempChild.setAttribute("aspect", 'poster')
    else:
        tempChild.setAttribute("aspect", 'thumb')

    root.appendChild(tempChild)

    if len(str(data['icon_poster'])) > 0:
        if settings.getBool('use_small_images', default=False) == True:
            nodeText = doc.createTextNode(
                str(data['icon_poster'].replace(
                    CONST_IMAGES['poster']['replace'],
                    CONST_IMAGES['poster']['small'])).strip())
        else:
            nodeText = doc.createTextNode(
                str(data['icon_poster'].replace(
                    CONST_IMAGES['poster']['replace'],
                    CONST_IMAGES['poster']['large'])).strip())
    elif len(str(data['icon_still'])) > 0:
        if settings.getBool('use_small_images', default=False) == True:
            nodeText = doc.createTextNode(
                str(data['icon_still'].replace(
                    CONST_IMAGES['still']['replace'],
                    CONST_IMAGES['still']['small'])).strip())
        else:
            nodeText = doc.createTextNode(
                str(data['icon_still'].replace(
                    CONST_IMAGES['still']['replace'],
                    CONST_IMAGES['still']['large'])).strip())

    tempChild.appendChild(nodeText)

    if not os.path.isfile(filename + '.nfo'):
        write_file(file=filename + '.nfo',
                   data=doc.toprettyxml(),
                   ext=True,
                   isJSON=False)
        return True
    else:
        if not load_file(filename + '.nfo', ext=True,
                         isJSON=False) == doc.toprettyxml():
            write_file(file=filename + '.nfo',
                       data=doc.toprettyxml(),
                       ext=True,
                       isJSON=False)

            if type == 'movie':
                method = 'VideoLibrary.GetMovies'
                basefilename = os.path.basename(os.path.normpath(filename))
                path = os.path.dirname(filename)
                params = {
                    "filter": {
                        "and": [{
                            "operator": "contains",
                            "field": "path",
                            "value": path
                        }, {
                            "operator": "is",
                            "field": "filename",
                            "value": str(basefilename) + '.strm'
                        }]
                    }
                }
                result = json_rpc(method, params)

                if result and check_key(
                        result, 'movies') and len(result['movies']) > 0:
                    libraryid = result['movies'][0]['movieid']

                    method = 'VideoLibrary.RefreshMovie'
                    params = {"movieid": libraryid}
                    result = json_rpc(method, params)

            elif type == 'show':
                method = 'VideoLibrary.GetTVShows'
                path = os.path.dirname(filename)
                params = {
                    "filter": {
                        "operator": "contains",
                        "field": "path",
                        "value": path
                    }
                }
                result = json_rpc(method, params)

                if result and check_key(
                        result, 'tvshows') and len(result['tvshows']) > 0:
                    libraryid = result['tvshows'][0]['tvshowid']

                    method = 'VideoLibrary.RefreshTVShow'
                    params = {"tvshowid": libraryid}
                    result = json_rpc(method, params)

            else:
                method = 'VideoLibrary.GetEpisodes'
                params = {
                    "filter": {
                        "operator": "contains",
                        "field": "filename",
                        "value": filename
                    }
                }
                result = json_rpc(method, params)

                if result and check_key(
                        result, 'episodes') and len(result['episodes']) > 0:
                    libraryid = result['episodes'][0]['episodeid']

                    method = 'VideoLibrary.RefreshEpisode'
                    params = {"episodeid": libraryid}
                    result = json_rpc(method, params)

            return True
        else:
            return False