def play_link(link):
    logger.log('Playing Link: |%s|' % (link), log_utils.LOGDEBUG)
    hmf = resolveurl.HostedMediaFile(url=link)
    if not hmf:
        logger.log('Indirect hoster_url not supported by smr: %s' % (link))
        kodi.notify('Link Not Supported: %s' % (link), duration=7500)
        return False
    logger.log('Link Supported: |%s|' % (link), log_utils.LOGDEBUG)

    try:
        stream_url = hmf.resolve()
        if not stream_url or not isinstance(stream_url, string_types):
            try:
                msg = stream_url.msg
            except:
                msg = link
                raise Exception(msg)
    except Exception as e:
        try:
            msg = str(e)
        except:
            msg = link
        kodi.notify('Resolve Failed: %s' % (msg), duration=7500)
        return False

    logger.log('Link Resolved: |%s|%s|' % (link, stream_url),
               log_utils.LOGDEBUG)

    listitem = xbmcgui.ListItem(path=stream_url)
    listitem.setContentLookup(False)
    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)
def create_dir(path, dir_name=None):
    if dir_name is None:
        dir_name = kodi.get_keyboard('Enter Directory Name')
        if dir_name is None:
            return

    try:
        os.mkdir(os.path.join(path, dir_name))
    except OSError as e:
        kodi.notify(msg=e.strerror)
    kodi.refresh_container()
def rename_dir(path, dir_name, new_name=None):
    if new_name is None:
        new_name = kodi.get_keyboard('Enter Directory Name', dir_name)
        if new_name is None:
            return

    old_path = os.path.join(path, dir_name)
    new_path = os.path.join(path, new_name)
    try:
        os.rename(old_path, new_path)
    except OSError as e:
        kodi.notify(msg=e.strerror)
    kodi.refresh_container()
Example #4
0
def play_link(link):
    logger.log('Playing Link: |%s|' % (link), log_utils.LOGDEBUG)
    if link.endswith('$$all'):
        hmf = resolveurl.HostedMediaFile(url=link[:-5], return_all=True)
    else:
        hmf = resolveurl.HostedMediaFile(url=link)
    if not hmf:
        logger.log('Indirect hoster_url not supported by smr: %s' % (link))
        kodi.notify('Link Not Supported: %s' % (link), duration=7500)
        return False
    logger.log('Link Supported: |%s|' % (link), log_utils.LOGDEBUG)

    try:
        if link.endswith('$$all'):
            allfiles = hmf.resolve()
            names = [x.get('name') for x in allfiles]
            item = xbmcgui.Dialog().select('Select file to play',
                                           names,
                                           preselect=0)
            if item == -1:
                return False
            stream_url = allfiles[item].get('link')
            if resolveurl.HostedMediaFile(stream_url):
                stream_url = resolveurl.resolve(stream_url)
        else:
            stream_url = hmf.resolve()
        if not stream_url or not isinstance(stream_url, string_types):
            try:
                msg = stream_url.msg
            except:
                msg = link
                raise Exception(msg)
    except Exception as e:
        try:
            msg = str(e)
        except:
            msg = link
        kodi.notify('Resolve Failed: %s' % (msg), duration=7500)
        return False

    logger.log('Link Resolved: |%s|%s|' % (link, stream_url),
               log_utils.LOGDEBUG)

    listitem = xbmcgui.ListItem(path=stream_url)
    # listitem.setContentLookup(False)
    xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, listitem)