Exemple #1
0
def plugin_process_watchlist(data):
    items = {}
    
    if check_key(data, 'details'):
        for row in data['details']:
            currow = data['details'][row]
            
            info = plugin_process_info({'info': currow})

            context = []
            
            params = []
            params.append(('_', 'remove_from_watchlist'))
            params.append(('id', currow['ref']))

            context.append((_.REMOVE_FROM_WATCHLIST, 'RunPlugin({context_url})'.format(context_url='plugin://{0}/?{1}'.format(ADDON_ID, urlencode(encode_obj(params)))), ))

            type = 'vod'
            
            if currow['type'] == 'series':
                params = []
                params.append(('_', 'vod_series'))
                params.append(('type', 'series'))
                params.append(('label', currow['title']))
                params.append(('id', currow['ref']))
            
                path = 'plugin://{0}/?{1}'.format(ADDON_ID, urlencode(encode_obj(params)))
                playable = False
                mediatype = ''
            elif currow['type'] == 'movie':
                params = []
                params.append(('_', 'play_video'))
                params.append(('type', type))
                params.append(('channel', None))
                params.append(('id', currow['ref']))
                params.append(('title', None))
                
                path = 'plugin://{0}/?{1}'.format(ADDON_ID, urlencode(encode_obj(params)))
                playable = True
                mediatype = 'video'
            else:
                continue

            items[str(currow['ref'])] = {
                'label1': info['label1'],
                'description': info['description'],
                'duration': info['duration'],
                'mediatype': mediatype,
                'image': info['image'],
                'image_large': info['image_large'],
                'path': path,
                'playable': playable,
                'context': context
            }
            
    log('DEBUG1111: ITEMS')
    log(items)

    return items
def addon_string(id):
    string = ADDON.getLocalizedString(id)

    if not string:
        log("LANGUAGE: Addon didn't return a string for id: {}".format(id))
        string = unicode(id)

    return string
Exemple #3
0
def upnext_notify(sender, message, data):
    """Send a notification to Kodi using JSON RPC"""

    result = upnext_jsonrpc(method='JSONRPC.NotifyAll',
                            params=dict(
                                sender=sender,
                                message=message,
                                data=data,
                            ))

    if result.get('result') != 'OK':
        log('Failed to send notification: ' +
            result.get('error').get('message'))
        return False

    return True
Exemple #4
0
def main():
    log('Start Dut-IPTV Library Updater service for {}'.format(PROVIDER_NAME))
    loop = True

    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"))

    while loop == True:
        start = int(time.time())

        update_library()

        end = int(time.time())

        if xbmc.Monitor().waitForAbort((start - end) + 3600):
            loop = False
Exemple #5
0
def update_library():
    #if check_loggedin(ADDON_ID):
    librarysettings = {}
    librarysettings['library_movies'] = settings.getInt(key='library_movies')
    librarysettings['library_shows'] = settings.getInt(key='library_shows')
    movies_added = False
    shows_added = False
    movies_removed = False
    shows_removed = False

    if librarysettings['library_movies'] == 0:
        for file in glob.glob(os.path.join(ADDON_PROFILE, "movies", "*.*")):
            movies_removed = True
            os.remove(file)

    if librarysettings['library_shows'] == 0:
        for file in glob.glob(os.path.join(ADDON_PROFILE, "shows", "*.*")):
            shows_removed = True
            os.remove(file)

    if librarysettings['library_movies'] > 0 or librarysettings[
            'library_shows'] > 0:
        log('Update Dut-IPTV Library for {}'.format(PROVIDER_NAME))

        skiplist = []
        skiplist2 = []

        if librarysettings['library_movies'] == 1 or librarysettings[
                'library_shows'] == 1:
            data = api_list_watchlist(type='watchlist')

            if data:
                processed = plugin_process_watchlist(data=data,
                                                     type='watchlist')

                if processed:
                    for ref in processed:
                        currow = processed[ref]

                        if currow['type'] == 'movie':
                            skiplist.append(ref)
                        elif currow['type'] == 'series':
                            skiplist2.append(ref)

        movie_list = []

        if librarysettings['library_movies'] > 0:
            for type in CONST_LIBRARY['movies']:
                if settings.getBool(key='library_movies_' + str(type),
                                    default=False):
                    result = create_stream(type, 'movies',
                                           librarysettings['library_movies'],
                                           skiplist)
                    movie_list.extend(result['list'])

                    if result['add'] == True:
                        movies_added = True

        for file in glob.glob(os.path.join(ADDON_PROFILE, "movies", "*.*")):
            filename = os.path.basename(file)

            if not filename in movie_list:
                movies_removed = True

                try:
                    os.remove(file)
                except:
                    pass

        shows_list = []
        remove_shows = []
        remove_shows2 = []

        if librarysettings['library_shows'] > 0:
            if librarysettings['library_shows'] == 2:
                api_get_series_nfo()

            for type in CONST_LIBRARY['shows']:
                if settings.getBool(key='library_shows_' + str(type),
                                    default=False):
                    result = create_stream(type, 'shows',
                                           librarysettings['library_shows'],
                                           skiplist2)
                    shows_list.extend(result['list'])

                    if result['add'] == True:
                        shows_added = True

        for file in glob.glob(os.path.join(ADDON_PROFILE, "shows", "*"),
                              recursive=False):
            filename = os.path.basename(os.path.normpath(file))

            if not filename in shows_list:
                shows_removed = True

                try:
                    os.remove(
                        os.path.join(ADDON_PROFILE, "shows", filename,
                                     'tvshow.nfo'))
                    remove_shows.append(
                        os.path.join(ADDON_PROFILE, "shows", filename, ""))
                except:
                    pass

        for file in glob.glob(os.path.join(ADDON_PROFILE, "shows", "*", "*",
                                           "*.*"),
                              recursive=False):
            filename = os.path.basename(file)

            if not filename in shows_list:
                shows_removed = True

                try:
                    os.remove(file)
                except:
                    pass

        index = 0

        for root, dirs, files in os.walk(os.path.join(ADDON_PROFILE, "shows")):
            for dir in dirs:
                newDir = os.path.join(root, dir)
                index += 1

                try:
                    os.removedirs(newDir)
                    remove_shows2.append(os.path.join(newDir, ""))
                    shows_removed = True
                except:
                    pass

        for removal in remove_shows:
            clean_library(show_dialog=False, path=removal)
            #Manual DB removal?

        for removal2 in remove_shows2:
            clean_library(show_dialog=False, path=removal2)
            #Manual DB removal?

        if movies_added == True or shows_added == True:
            if movies_added == True:
                scan_library(show_dialog=False,
                             path=os.path.join(ADDON_PROFILE, "movies", ""))

            if shows_added == True:
                scan_library(show_dialog=False,
                             path=os.path.join(ADDON_PROFILE, "shows", ""))

    if movies_removed == True or shows_removed == True:
        clean_library(show_dialog=False)
Exemple #6
0
def api_play_url(type,
                 channel=None,
                 id=None,
                 video_data=None,
                 from_beginning=0,
                 pvr=0):
    playdata = {'path': '', 'license': '', 'info': '', 'properties': {}}

    if not api_get_session():
        return playdata

    profile_settings = load_profile(profile_id=1)
    info = {}
    properties = {}

    if not type or not len(str(type)) > 0:
        return playdata

    headers = {
        'videoland-platform': 'videoland',
    }

    if id.startswith('E'):
        typestr = 'episode'
        id = id[1:]
        id_ar = id.split('###')
        series = id_ar[0]
        season = id_ar[1]
        id = id_ar[2]
        info_url = '{base_url}/api/v3/episodes/{series}/{season}'.format(
            base_url=CONST_BASE_URL, series=series, season=season)
    elif id.startswith('M'):
        typestr = 'movie'
        id = id[1:]
        info_url = '{base_url}/api/v3/movies/{id}'.format(
            base_url=CONST_BASE_URL, id=id)
    else:
        return playdata

    download = api_download(url=info_url,
                            type='get',
                            headers=headers,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if code and code == 200 and data:
        if typestr == 'episode':
            log('E' + str(id))

            if check_key(data, 'details') and check_key(
                    data['details'], 'E' + str(id)):
                info = data['details']['E' + str(id)]
        else:
            info = data

    play_url_path = '{base_url}/api/v3/stream/{id}/widevine?edition=&profile_id={profile_id}'.format(
        base_url=CONST_BASE_URL,
        id=id,
        profile_id=profile_settings['profile_id'])

    download = api_download(url=play_url_path,
                            type='get',
                            headers=headers,
                            data=None,
                            json_data=False,
                            return_json=True)
    data = download['data']
    code = download['code']

    if not code or not code == 200 or not data or not check_key(
            data, 'id') or not check_key(data, 'ticket_id') or not check_key(
                data, 'stream') or not check_key(data['stream'], 'dash'):
        return playdata

    path = data['stream']['dash']

    if check_key(data, 'drm'):
        license = data['drm']

    profile_settings['ticket_id'] = data['ticket_id']
    profile_settings['token'] = data['stream']['token']
    save_profile(profile_id=1, profile=profile_settings)

    playdata = {
        'path': path,
        'license': license,
        'info': info,
        'properties': properties
    }

    return playdata