Beispiel #1
0
def listRecordings():
	recordings=[]
	defaultrecording=str(plugin.get_setting("defaultrecording", unicode))
	alllanguages = sorted(bibledata.languagelib)
	for language in alllanguages:
		thislanguage = bibledata.languagelib[language]
		recordings.append({'label': thislanguage['title'], 
                            'path': plugin.url_for('listRecordings'),
                            'icon': 'DefaultShortcut.png'})
		for index in bibledata.recordinglib:
			recording = dict(bibledata.recordinglib[index])
			if recording['language']==language:
				alabel = recording['title']
				if recording['code']==defaultrecording:
					alabel=alabel + " (Current Default Recording)"
				recordings.append(
				{'label': alabel, 
				'path': plugin.url_for('listBooks', recording=recording['code']),
				'context_menu':[
					makedefaultrecording(recording['code'])
				],
				'icon': 'DefaultArtist.png'
				}
				)
		if forceViewMode=="true":
			xbmc.executebuiltin('Container.SetViewMode('+viewMode+')')
	return plugin.finish(recordings)
Beispiel #2
0
def move_channel_down(channel):
    channels = get_channels()
    old_index = channels.index(channel)
    new_index = old_index + 1
    if old_index >= 0:
        channels.insert(new_index, channels.pop(old_index))
    xbmc.executebuiltin("Container.Refresh")
Beispiel #3
0
def AddPlaylist(tracking_string="Add Playlist"):
    sheet_url = plugin.keyboard(
        heading=
        'Nhập URL của Google Spreadsheet (có hỗ trợ link rút gọn như bit.ly, goo.gl)'
    )
    if sheet_url:
        try:
            resp, content = http.request(sheet_url, "HEAD")
            sid, gid = re.compile("/d/(.+?)/.+?gid=(\d+)").findall(
                resp["content-location"])[0]
            match_passw = re.search('passw=(.+?)($|&)',
                                    resp["content-location"])
            playlists = plugin.get_storage('playlists')
            name = plugin.keyboard(heading='Đặt tên cho Playlist')

            item = "[[COLOR yellow]%s[/COLOR]] %s@%s" % (name, gid, sid)
            if match_passw:
                item += "@@" + match_passw.group(1)
            if 'sections' in playlists:
                playlists["sections"] = [item] + playlists["sections"]
            else:
                playlists["sections"] = [item]
            xbmc.executebuiltin('Container.Refresh')
        except:
            line1 = "Vui lòng nhập URL hợp lệ. Ví dụ dạng đầy đủ:"
            line2 = "http://docs.google.com/spreadsheets/d/xxx/edit#gid=###"
            line3 = "Hoặc rút gọn: http://bit.ly/xxxxxx hoặc http://goo.gl/xxxxx"
            dlg = xbmcgui.Dialog()
            dlg.ok("URL không hợp lệ!!!", line1, line2, line3)
Beispiel #4
0
def listBooks(recording):
    thisrecording = bibledata.recordinglib[recording]
    print(recording)
    books = []
    allBooks = bibledata.booklib
    codes = dict(bibledata.bookorderlib)
    #for code, title in match:
    for item in codes:
        code = codes[item]
        book = dict(allBooks[code])
        title = book['title']
        #or (bibledata.pluswisdom[recording] <> '' and (code=='Prov' or code=='Ps'))
        if book['section'] == thisrecording['section'] or thisrecording[
                'section'] == 'ALL' or (thisrecording['pluswisdom'] == 1 and
                                        (code == 'Prov' or code == 'Ps')):
            books.append({
                'label':
                title,
                'path':
                plugin.url_for('listChapters', recording=recording, book=code),
                'icon':
                'DefaultPlaylist.png'
            })
    if forceViewMode == "true":
        xbmc.executebuiltin('Container.SetViewMode(' + viewMode + ')')
    return plugin.finish(books)
Beispiel #5
0
def search(search_func, term = None):
    """ Search wrapper """
    external = False
    if plugin.id == xbmc.getInfoLabel('Container.PluginName'):
        # Skip if search item isn't currently selected    
        label = xbmc.getInfoLabel('ListItem.label')
        if label and not equals(label, _("Search")):
            return
    else:
        external = True

    if term is None:
        # Get search keyword
        search_entered = plugin.keyboard(heading=_("search for"))
        if not search_entered:
            return

    else:
        search_entered = term
    # Perform search
    url = plugin.url_for(search_func, term=search_entered, page='1')
    if external:
        xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' % plugin.id)
        xbmc.executebuiltin('Container.Update("%s")' % url)
    else:
        plugin.redirect(url)
Beispiel #6
0
def listRecordings():
    recordings = []
    defaultrecording = str(plugin.get_setting("defaultrecording", unicode))
    alllanguages = sorted(bibledata.languagelib)
    for language in alllanguages:
        thislanguage = bibledata.languagelib[language]
        recordings.append({
            'label': thislanguage['title'],
            'path': plugin.url_for('listRecordings'),
            'icon': 'DefaultShortcut.png'
        })
        for index in bibledata.recordinglib:
            recording = dict(bibledata.recordinglib[index])
            if recording['language'] == language:
                alabel = recording['title']
                if recording['code'] == defaultrecording:
                    alabel = alabel + " (Current Default Recording)"
                recordings.append({
                    'label':
                    alabel,
                    'path':
                    plugin.url_for('listBooks', recording=recording['code']),
                    'context_menu': [makedefaultrecording(recording['code'])],
                    'icon':
                    'DefaultArtist.png'
                })
        if forceViewMode == "true":
            xbmc.executebuiltin('Container.SetViewMode(' + viewMode + ')')
    return plugin.finish(recordings)
Beispiel #7
0
def PasswordSection(password="******", path = "0", tracking_string = "Home"):
	'''
	Liệt kê danh sách các item của một sheet
	Parameters
	----------
	path : string
		"gid" của sheet
	tracking_string : string
		 Tên dễ đọc của view
	'''
	GA( # tracking
		"Password Section - %s" % tracking_string,
		"/password-section/%s" % path
	)
	passwords = plugin.get_storage('passwords')
	if password in passwords and (time.time() - passwords[password] < 1800):
		items = AddTracking(getItems(path))
		return plugin.finish(items)
	else:
		passw_string = plugin.keyboard(heading='Nhập password')
		if passw_string == password:
			passwords[password] = time.time()
			items = AddTracking(getItems(path))
			return plugin.finish(items)
		else:
			header  = "Sai mật khẩu!!!"
			message = "Mật khẩu không khớp. Không tải được nội dung"
			xbmc.executebuiltin('Notification("%s", "%s", "%d", "%s")' % (header, message, 10000, ''))
			return plugin.finish()
Beispiel #8
0
def I11i1i11i1I(murl, page):
    Oo = o00(murl, page, 'added')
    if xbmc.getSkinDir() == 'skin.xeebo' and oo000.get_setting(
            'thumbview', bool):
        xbmc.executebuiltin('Container.SetViewMode(52)')
    return oo000.finish(Oo)
    if 31 - 31: Oo0Ooo / IiII / oo00000o0 * O0oO / I1Ii111
def AddPlaylist(tracking_string="Add Playlist"):
	sheet_url = plugin.keyboard(
		heading='Nhập URL của Google Spreadsheet (có hỗ trợ link rút gọn như bit.ly, goo.gl)')
	if sheet_url:
		if not re.match("^https*://", sheet_url):
			sheet_url = "https://" + sheet_url
		try:
			resp, content = http.request(sheet_url, "HEAD")
			sid, gid = re.compile(
				"/d/(.+?)/.+?gid=(\d+)").findall(resp["content-location"])[0]
			match_passw = re.search('passw=(.+?)($|&)', resp["content-location"])
			playlists = plugin.get_storage('playlists')
			name = plugin.keyboard(heading='Đặt tên cho Playlist')

			item = "[[COLOR yellow]%s[/COLOR]] %s@%s" % (name, gid, sid)
			if match_passw:
				item += "@@" + match_passw.group(1)
			if 'sections' in playlists:
				playlists["sections"] = [item] + playlists["sections"]
			else:
				playlists["sections"] = [item]
			xbmc.executebuiltin('Container.Refresh')
		except:
			line1 = "Vui lòng nhập URL hợp lệ. Ví dụ dạng đầy đủ:"
			line2 = "http://docs.google.com/spreadsheets/d/xxx/edit#gid=###"
			line3 = "Hoặc rút gọn: http://bit.ly/xxxxxx hoặc http://goo.gl/xxxxx"
			dlg = xbmcgui.Dialog()
			dlg.ok("URL không hợp lệ!!!", line1, line2, line3)
Beispiel #10
0
def lists_trakt_add_liked_to_library():
    lists, pages = trakt.trakt_get_liked_lists(1)
    misc_ids = []
    movie_ids = []
    tv_ids = []
    import xbmcgui
    pDialog = xbmcgui.DialogProgress()
    pDialog.create('[COLOR ff0084ff]M[/COLOR]etalli[COLOR ff0084ff]Q[/COLOR]', 'Creating batch import files')
    for page in range(0, int(pages)):
        lists, ignore = trakt.trakt_get_liked_lists(page)
        list_number = 1
        if (pDialog.iscanceled()): return
        percent = (int(page) / int(pages)) * 100
        pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages))
        for list in lists:
            list_number += 1
            pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages), 'list {0} of {1} on page'.format(list_number, len(lists) + 1))
            info = list["list"]
            user = info["user"]["username"]
            slug = info["ids"]["slug"]
            items = lists_trakt_show_list(user, slug)
            list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items)
            write_list_id_files(list_misc_ids, list_movie_ids, list_tv_ids, slug, user)
            misc_ids.extend(list_misc_ids)
            movie_ids.extend(list_movie_ids)
            tv_ids.extend(list_tv_ids)
    pDialog.close()
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("metalliq"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
Beispiel #11
0
def lists_trakt_add_all_to_library(user, slug):
    items = lists_trakt_show_list(user, slug, raw=True)
    misc_ids, movie_ids, tv_ids = batch_find_list_ids(items)
    write_list_id_files(misc_ids, tv_ids, movie_ids, slug, user)
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Conversion done', title='starting batch-add', delay=3000, image=get_icon_path("metalliq"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
Beispiel #12
0
def scan_library(type="video"):
    while not xbmc.abortRequested and \
     (xbmc.getCondVisibility('Library.IsScanning') or \
     xbmc.getCondVisibility('Window.IsActive(progressdialog)')):
        xbmc.sleep(1000)
    xbmc.executebuiltin('UpdateLibrary(video)')
    xbmc.executebuiltin('UpdateLibrary(music)')
def PasswordSection(password="******", path="0", tracking_string="Home"):
	'''
	Liệt kê danh sách các item của một sheet
	Parameters
	----------
	path : string
		"gid" của sheet
	tracking_string : string
		 Tên dễ đọc của view
	'''
	GA(  # tracking
		"Password Section - %s" % tracking_string,
		"/password-section/%s" % path
	)
	passwords = plugin.get_storage('passwords')
	if password in passwords and (time.time() - passwords[password] < 1800):
		items = AddTracking(getItems(path))
		return plugin.finish(items)
	else:
		passw_string = plugin.keyboard(heading='Nhập password')
		if passw_string == password:
			passwords[password] = time.time()
			items = AddTracking(getItems(path))
			return plugin.finish(items)
		else:
			header = "Sai mật khẩu!!!"
			message = "Mật khẩu không khớp. Không tải được nội dung"
			xbmc.executebuiltin('Notification("%s", "%s", "%d", "%s")' %
			                    (header, message, 10000, ''))
			return plugin.finish()
Beispiel #14
0
def lists_trakt_add_all_to_library(user, slug):
    items = lists_trakt_show_list(user, slug, raw=True)
    misc_ids, movie_ids, tv_ids = batch_find_list_ids(items)
    write_list_id_files(misc_ids, tv_ids, movie_ids, slug, user)
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Conversion done', title='starting batch-add', delay=3000, image=get_icon_path("chappaai"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/movies/batch_add_to_library)")
Beispiel #15
0
def search(search_func, term=None):
    """ Search wrapper """
    external = False
    if plugin.id == xbmc.getInfoLabel('Container.PluginName'):
        # Skip if search item isn't currently selected
        label = xbmc.getInfoLabel('ListItem.label')
        if label and not equals(label, _("Search")):
            return
    else:
        external = True

    if term is None:
        # Get search keyword
        search_entered = plugin.keyboard(heading=_("search for"))
        if not search_entered:
            return

    else:
        search_entered = term
    # Perform search
    url = plugin.url_for(search_func, term=search_entered, page='1')
    if external:
        xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' %
                            plugin.id)
        xbmc.executebuiltin('Container.Update("%s")' % url)
    else:
        plugin.redirect(url)
Beispiel #16
0
def main():
    channel = []
    result = urlfetch.fetch(__homeUrl__,headers=reg)
    soup = BeautifulSoup(result.content, convertEntities=BeautifulSoup.HTML_ENTITIES)
    items = soup.findAll('div', {'class' : 'item_view'})
    for item in items:
            
        common = item.find('a', {'class' : 'tv_channel '})
        if common == None :
          common = item.find('a', {'class' : 'tv_channel active'})

        lock = item.find('img', {'class' : 'lock'})
        if lock == None :

          title = common.get('title')       
          url = common.get('data-href')
          thumb = common.find('img',{'class':'img-responsive'}).get('data-original')
          thumb = thumb.split('?')
          if 'giai-tri-tv' in url or 'phim-viet' in url or 'the-thao-tv-hd' in url or 'kenh-17' in url or 'e-channel' in url or 'hay-tv' in url or 'ddramas' in url or 'bibi' in url or 'o2-tv' in url or 'info-tv' in url or 'style-tv' in url or 'invest-tv' in url or 'yeah1' in url:
            pass
          else :		  
            data = {
                'label': title.replace('-',' '),
                'path': xbmcplugin.url_for('plays', id = url.replace('http://fptplay.net/livetv/','')),
                'thumbnail':thumb[0],
                'is_playable': True
                }
            channel.append(data)

    xbmc.executebuiltin('Container.SetViewMode(%d)' % 500)		
    return xbmcplugin . finish ( channel )
Beispiel #17
0
def o0o00o0():
    i1IIi11111i("Login", "/login")
    xbmc.executebuiltin('Dialog.Close(busydialog)')
    try:
        iIi1ii1I1 = requests.get(
            "http://echipstore.com/get-code/?nocache=true").json()
        o0 = iIi1ii1I1["message"] % iIi1ii1I1["user_code"].upper()
        I11II1i = xbmcgui.DialogProgress()
        I11II1i.create('Login', o0)
        if 23 - 23: ooO00oOoo / iiI1i1 + i1iIIII + i1iIIII / Iii1IIIiiI
        iiI1 = 0
        while iiI1 < 60:
            i11Iiii = int((iiI1 / 60.0) * 100)
            if I11II1i.iscanceled():
                break
            I11II1i.update(i11Iiii, "")
            iiI1 = iiI1 + 1
            xbmc.sleep(5000)
            iII1i1I1II = requests.get(
                "http://echipstore.com/device?device_code=%s&nocache=true" %
                urllib.quote_plus(iIi1ii1I1["device_code"]))
            if "token" in iII1i1I1II.text:
                o0O.setSetting("token", iII1i1I1II.json()["token"])
                o0O.setSetting("email", iII1i1I1II.json()["email"])
                break
        I11II1i.close()
        del I11II1i
        xbmc.executebuiltin('XBMC.Container.Update(%s)' % iI11I1II1I1I)
    except:
        i1 = xbmcgui.Dialog()
        i1.ok("Oops!", "Có lỗi xảy ra. Xin quý vị vui lòng login vào dịp khác")
        if 48 - 48: ooO0OO000o + ooO0OO000o - ooO00oOoo.i1iIIIiI1I / I11i11Ii
Beispiel #18
0
def movies_batch_add_to_library():
    """ Batch add movies to library """
    movie_batch_file = plugin.get_setting(SETTING_MOVIES_BATCH_ADD_FILE_PATH)
    if xbmcvfs.exists(movie_batch_file):
        try:
            f = open(xbmc.translatePath(movie_batch_file), 'r')
            r = f.read()
            f.close()
            ids = r.split('\n')
        except: return plugin.notify(msg='Movies Batch Add File', title='Not found', delay=3000, image=get_icon_path("movies"))
        library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER))
        import_tmdb()
        for id in ids:
            if "," in id:
                csvs = id.split(',')
                for csv in csvs:
                    if not str(csv).startswith("tt") and csv != "":
                        movie = tmdb.Movies(csv).info()
                        id = movie.get('imdb_id')
                    batch_add_movies_to_library(library_folder, id)
            else:
                if not str(id).startswith("tt") and id != "":
                    movie = tmdb.Movies(id).info()
                    id = movie.get('imdb_id')
                batch_add_movies_to_library(library_folder, id)
        os.remove(xbmc.translatePath(movie_batch_file))
        if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): 
            xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
            return True
        else:
            xbmc.sleep(1000)
            plugin.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies"))
            scan_library(type="video")
            return True
    elif xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/batch_add_to_library)")
Beispiel #19
0
def move_channel_down(channel):
    channels = get_channels()
    old_index = channels.index(channel)
    new_index = old_index + 1
    if old_index >= 0:
        channels.insert(new_index, channels.pop(old_index))
    xbmc.executebuiltin("Container.Refresh")
Beispiel #20
0
def IIIiI11ii(search_string):
    Oo = O000oo(search_string, 'search')
    if xbmc.getSkinDir() == 'skin.xeebo' and oo000.get_setting(
            'thumbview', bool):
        xbmc.executebuiltin('Container.SetViewMode(52)')
    return oo000.finish(Oo)
    if 3 - 3: iIi1IIii11I + OO0OO0O0O0
Beispiel #21
0
def remove_channel(channel):
    channels = get_channels()
    try:
        channels.remove(channel)
    except:
        pass
    xbmc.executebuiltin("Container.Refresh")
Beispiel #22
0
def oo00(murl, page):
    Oo = o00(murl, page, 'updated')
    if xbmc.getSkinDir() == 'skin.xeebo' and oo000.get_setting(
            'thumbview', bool):
        xbmc.executebuiltin('Container.SetViewMode(52)')
    return oo000.finish(Oo)
    if 62 - 62: II1ii - o0oOoO00o.iIi1IIii11I + oo0 * Ooo0 % oo00000o0
Beispiel #23
0
def on_play_video(mode, players, params, trakt_ids=None):
    assert players
    # Cancel resolve
    action_cancel()
    # Get video link
    use_simple_selector = plugin.get_setting(SETTING_USE_SIMPLE_SELECTOR, converter=bool)
    is_extended = not (use_simple_selector or len(players) == 1)
    if not is_extended:
        xbmc.executebuiltin("ActivateWindow(busydialog)")
    try:
        selection = get_video_link(players, params, mode, use_simple_selector)
    finally:
        if not is_extended:
            xbmc.executebuiltin("Dialog.Close(busydialog)")
    if not selection:
        return
    # Get selection details
    link = selection["path"]
    action = selection.get("action", "")
    plugin.log.info("Playing url: %s" % to_utf8(link))
    # Activate link
    if action == "ACTIVATE":
        action_activate(link)
    else:
        if trakt_ids:
            set_property("script.trakt.ids", json.dumps(trakt_ids))
        return link
    return None
Beispiel #24
0
def lists_trakt_add_my_lists_to_library():
    misc_ids = []
    movie_ids = []
    tv_ids = []
    import xbmcgui
    lists = trakt.trakt_get_lists()
    dialogs.notify(msg='Adding ' + str(len(lists)) + " lists",
                   title='to Kodi library',
                   delay=3000,
                   image=get_icon_path("default"))
    for list in lists:
        user = list["user"]["username"]
        slug = list["ids"]["slug"]
        items = lists_trakt_show_list(user, slug)
        list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items)
        write_list_id_files(list_misc_ids, list_tv_ids, list_movie_ids, slug,
                            user)
        misc_ids.extend(list_misc_ids)
        movie_ids.extend(list_movie_ids)
        tv_ids.extend(list_tv_ids)
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Generating',
                   title='.strm-files',
                   delay=3000,
                   image=get_icon_path("default"))
    xbmc.executebuiltin(
        "RunPlugin(plugin://plugin.video.metalliq-forqed/movies/batch_add_to_library)"
    )
Beispiel #25
0
def lists_trakt_add_liked_to_library():
    lists, pages = trakt.trakt_get_liked_lists(1)
    misc_ids = []
    movie_ids = []
    tv_ids = []
    import xbmcgui
    pDialog = xbmcgui.DialogProgress()
    pDialog.create('Chappaai', 'Creating batch import files')
    for page in range(0, int(pages)):
        lists, ignore = trakt.trakt_get_liked_lists(page)
        list_number = 1
        if (pDialog.iscanceled()): return
        percent = (int(page) / int(pages)) * 100
        pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages))
        for list in lists:
            list_number += 1
            pDialog.update(int(percent), '{0} {1} of {2} ...        '.format(_("Scanning for new content"), page, pages), 'list {0} of {1} on page'.format(list_number, len(lists) + 1))
            info = list["list"]
            user = info["user"]["username"]
            slug = info["ids"]["slug"]
            items = lists_trakt_show_list(user, slug)
            list_misc_ids, list_movie_ids, list_tv_ids = batch_find_list_ids(items)
            write_list_id_files(list_misc_ids, list_movie_ids, list_tv_ids, slug, user)
            misc_ids.extend(list_misc_ids)
            movie_ids.extend(list_movie_ids)
            tv_ids.extend(list_tv_ids)
    pDialog.close()
    write_batch_id_files(tv_ids, movie_ids, misc_ids)
    dialogs.notify(msg='Generating', title='.strm-files', delay=3000, image=get_icon_path("chappaai"))
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/movies/batch_add_to_library)")
Beispiel #26
0
def movies_batch_add_to_library():
    """ Batch add movies to library """
    movie_batch_file = plugin.get_setting(SETTING_MOVIES_BATCH_ADD_FILE_PATH, unicode)
    if xbmcvfs.exists(movie_batch_file):
        try:
            f = open(xbmc.translatePath(movie_batch_file), 'r')
            r = f.read()
            f.close()
            ids = r.split('\n')
        except: return dialogs.notify(msg='Movies Batch Add File', title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies"))
        library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode))
        import_tmdb()
        for id in ids:
            if "," in id:
                csvs = id.split(',')
                for csv in csvs:
                    if not str(csv).startswith("tt") and csv != "":
                        movie = tmdb.Movies(csv).info()
                        csv = movie.get('imdb_id')
                    batch_add_movies_to_library(library_folder, csv)
            else:
                if not str(id).startswith("tt") and id != "":
                    movie = tmdb.Movies(id).info()
                    id = movie.get('imdb_id')
                batch_add_movies_to_library(library_folder, id)
        os.remove(xbmc.translatePath(movie_batch_file))
        if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)):
            xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/tv/batch_add_to_library)")
            return True
        else:
            xbmc.sleep(1000)
            dialogs.notify(msg='Added movie strm-files', title='Starting library scan', delay=3000, image=get_icon_path("movies"))
            scan_library(type="video")
            return True
    if xbmcvfs.exists(plugin.get_setting(SETTING_TV_BATCH_ADD_FILE_PATH, unicode)): xbmc.executebuiltin("RunPlugin(plugin://plugin.video.chappaai/tv/batch_add_to_library)")
Beispiel #27
0
def scan_library(type="video"):
    while not xbmc.abortRequested and \
     (xbmc.getCondVisibility('Library.IsScanning') or \
     xbmc.getCondVisibility('Window.IsActive(progressdialog)')):
        xbmc.sleep(1000)
    xbmc.executebuiltin('UpdateLibrary(video)')
    xbmc.executebuiltin('UpdateLibrary(music)')
Beispiel #28
0
def on_play_video(mode, players, params, trakt_ids=None):
    assert players
    # Cancel resolve
    action_cancel()
    # Get video link
    use_simple_selector = plugin.get_setting(SETTING_USE_SIMPLE_SELECTOR, bool)
    is_extended = not (use_simple_selector or len(players) == 1)
    if not is_extended: xbmc.executebuiltin("ActivateWindow(busydialog)")
    try:
        selection = get_video_link(players, params, mode, use_simple_selector)
    finally:
        if not is_extended: xbmc.executebuiltin("Dialog.Close(busydialog)")
    if not selection: return
    # Get selection details
    link = selection['path']
    action = selection.get('action', '')
    plugin.log.info('Playing url: %s' % to_utf8(link))
    # Activate link
    if action == "ACTIVATE": action_activate(link)
    elif action == "RUN": action_run(link)
    elif action == "PRERUN": action_prerun(link)
    else:
        if trakt_ids: set_property('script.trakt.ids', json.dumps(trakt_ids))
        return link
    return None
Beispiel #29
0
def remove_channel(channel):
    channels = get_channels()
    try:
        channels.remove(channel)
    except:
        pass
    xbmc.executebuiltin("Container.Refresh")
Beispiel #30
0
def batch_add_movies_to_library(library_folder, id):
    if id == None:
        return
    changed = False
    movie_folder = os.path.join(library_folder, str(id) + "/")
    if not xbmcvfs.exists(movie_folder):
        try:
            xbmcvfs.mkdir(movie_folder)
        except:
            pass
    nfo_filepath = os.path.join(movie_folder, str(id) + ".nfo")
    if not xbmcvfs.exists(nfo_filepath):
        changed = True
        nfo_file = xbmcvfs.File(nfo_filepath, "w")
        content = "http://www.imdb.com/title/%s/" % str(id)
        nfo_file.write(content)
        nfo_file.close()
    strm_filepath = os.path.join(movie_folder, str(id) + ".strm")
    src = "imdb"
    if not xbmcvfs.exists(strm_filepath):
        changed = True
        strm_file = xbmcvfs.File(strm_filepath, "w")
        try:
            content = plugin.url_for("movies_play", src=src, id=id, mode="library")
            strm_file.write(content)
            strm_file.close()
        except:
            pass
    if xbmc.getCondVisibility("system.hasaddon(script.qlickplay)"):
        xbmc.executebuiltin("RunScript(script.qlickplay,info=afteradd)")
    if xbmc.getCondVisibility("system.hasaddon(script.extendedinfo)"):
        xbmc.executebuiltin("RunScript(script.extendedinfo,info=afteradd)")
    return changed
Beispiel #31
0
def show_note_btih(userid, note_id, category_id):
    api = get_api(userid)
    notes = [n for n in api.list_note(category_id) if n['_key'] == note_id]
    if notes:
        tmpfile = 'special://temp/_baidu_note.bth'
        xbmcvfs.File(tmpfile, 'w').write(notes[0]['content'].encode('utf-8'))
        xbmc.executebuiltin(
            'Container.Update(plugin://script.module.hdpparser?parser=bth&uri=special%3A%2F%2Ftemp%2F_baidu_note.bth)')  # noqa
Beispiel #32
0
def open_dir():
    dialog = xbmcgui.Dialog()
    dirpath = dialog.browse(0, u'请选择需要打开的目录', 'files')
    if not dirpath:
        return

    xbmc.executebuiltin(
        'Container.Update(plugin://script.module.hdpparser?parser=listdir&uri=%s)' % quote_plus(dirpath))  # noqa
Beispiel #33
0
def show_note_btih(userid, note_id, category_id):
    api = get_api(userid)
    notes = [n for n in api.list_note(category_id) if n['_key'] == note_id]
    if notes:
        tmpfile = 'special://temp/_baidu_note.bth'
        xbmcvfs.File(tmpfile, 'w').write(notes[0]['content'].encode('utf-8'))
        xbmc.executebuiltin(
            'Container.Update(plugin://script.module.hdpparser?parser=bth&uri=special%3A%2F%2Ftemp%2F_baidu_note.bth)')  # noqa
Beispiel #34
0
def execbuiltin(path,tracking_string=""):
	GA( # tracking
		"Execute Builtin - %s" % tracking_string,
		"/repo-execbuiltin/%s" % path
	)
	try:
		xbmc.executebuiltin('XBMC.RunPlugin(%s)' % urllib.unquote_plus(path))
	except: pass
Beispiel #35
0
def live_search_term(term):
    """ Perform search of a specified <term>"""
    term = to_utf8(term)
    channels = get_channels()
    if term not in channels:
        channels.append(term)
        xbmc.executebuiltin("Container.Refresh")
    return live_play(term)
Beispiel #36
0
 def mark_as_watched(self):
     if not self.id:
         return
             
     RPC.video_library.set_episode_details(episodeid = self.id, \
         playcount=1, resume={"position": 0})
     
     xbmc.executebuiltin('Container.Refresh')
Beispiel #37
0
def delete_tracking(sid, cookie):
    req = requests.get(API + '/tracking/delete/sid/{0}'.format(sid),
                       cookies={'Sdarot': cookie},
                       headers=HEADERS)
    if req.json()['success']:
        xbmc.executebuiltin('Container.Refresh')
        plugin.notify('סדרה הוסרה!')
    pass
Beispiel #38
0
def action_prerun(link):
#    xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)')
    if link.startswith("plugin://"):
        id = link.split("/")
        xbmc.executebuiltin('RunAddon(%s)' % id[2])
        while xbmc.getInfoLabel('Container.PluginName') != id[2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'): xbmc.sleep(250)
        xbmc.sleep(250)
        xbmc.executebuiltin('Container.Update("%s")' % link)
Beispiel #39
0
def open_dir():
    dialog = xbmcgui.Dialog()
    dirpath = dialog.browse(0, u'请选择需要打开的目录', 'files')
    if not dirpath:
        return

    xbmc.executebuiltin(
        'Container.Update(plugin://script.module.hdpparser?parser=listdir&uri=%s)' % quote_plus(dirpath))  # noqa
Beispiel #40
0
    def mark_as_watched(self):
        if not self.id:
            return

        RPC.video_library.set_episode_details(episodeid = self.id, \
            playcount=1, resume={"position": 0})

        xbmc.executebuiltin('Container.Refresh')
Beispiel #41
0
def execbuiltin(path, tracking_string=""):
    GA(  # tracking
        "Execute Builtin - %s" % tracking_string,
        "/repo-execbuiltin/%s" % path)
    try:
        xbmc.executebuiltin('XBMC.RunPlugin(%s)' % urllib.unquote_plus(path))
    except:
        pass
def live_search_term(term):
    """ Perform search of a specified <term>"""
    term = to_utf8(term)
    channels = get_channels()
    if term not in channels:
        channels.append(term)
        xbmc.executebuiltin("Container.Refresh")
    return live_play(term)
def InstallRepo(path = "0", tracking_string = ""):
	'''
	Cài đặt repo
	Parameters
	----------
	path : string
		Nếu truyền "gid" của Repositories sheet:
			Cài tự động toàn bộ repo trong Repositories sheet
		Nếu truyền link download zip repo
			Download và cài zip repo đó
	tracking_string : string
		 Tên dễ đọc của view
	'''
	GA( # tracking
		"Install Repo - %s" % tracking_string,
		"/install-repo/%s" % path
	)
	if path.isdigit(): # xác định GID
		pDialog = xbmcgui.DialogProgress()
		pDialog.create('Vui lòng đợi','Đang cập nhật','Đang tải...')
		items = getItems(path)
		total = len(items)
		i = 0
		failed = []
		for item in items:
			done = int(100 * i / total)
			pDialog.update(done,'Đang tải', item["label2"] + '...')
			try:
				item["path"] = "http" + item["path"].split("http")[-1]
				download(urllib.unquote_plus(item["path"]), item["label2"])
			except:
				failed += [item["label"].encode("utf-8")]
			if pDialog.iscanceled():
				break
			i+=1
		pDialog.close()
		if len(failed) > 0:
			dlg = xbmcgui.Dialog()
			s = "Không thể cài các rep sau:\n[COLOR orange]%s[/COLOR]" % "\n".join(failed)
			dlg.ok('Chú ý: Không cài đủ repo!', s)
		else:
			dlg = xbmcgui.Dialog()
			s = "Đã cập nhật thành công"
			dlg.ok('Cập nhật xong!', s)

	else: # cài repo riêng lẻ
		try:
			download(path, "")
			dlg = xbmcgui.Dialog()
			s = "Repo %s đã được cài thành công" % tracking_string
			dlg.ok('Cài Repo thành công!', s)
		except:
			dlg = xbmcgui.Dialog()
			s = "Vùi lòng thử cài lại lần sau"
			dlg.ok('Cài repo thất bại!', s)

	xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
	xbmc.executebuiltin("XBMC.UpdateAddonRepos()")
Beispiel #44
0
def show_note_btih(userid, note_id, category_id):
    api = get_api(userid)
    notes = [n for n in api.list_note(category_id) if n["_key"] == note_id]
    if notes:
        tmpfile = "special://temp/_baidu_note.bth"
        xbmcvfs.File(tmpfile, "w").write(notes[0]["content"].encode("utf-8"))
        xbmc.executebuiltin(
            "Container.Update(plugin://script.module.hdpparser?parser=bth&uri=special%3A%2F%2Ftemp%2F_baidu_note.bth)"
        )  # noqa
Beispiel #45
0
def remove_fav(_id):
    try:
        favs = plugin.get_storage('favourites')
        del favs[_id]
    except KeyError:
        plugin.notify('הייתה בעיה, נסה שוב', image=ICON)

    xbmc.executebuiltin('Container.Refresh')
    pass
Beispiel #46
0
def InstallRepo(path="0", tracking_string=""):
    '''
	Cài đặt repo
	Parameters
	----------
	path : string
		Nếu truyền "gid" của Repositories sheet:
			Cài tự động toàn bộ repo trong Repositories sheet
		Nếu truyền link download zip repo
			Download và cài zip repo đó
	tracking_string : string
		 Tên dễ đọc của view
	'''
    GA(  # tracking
        "Install Repo - %s" % tracking_string, "/install-repo/%s" % path)
    if path.isdigit():  # xác định GID
        pDialog = xbmcgui.DialogProgress()
        pDialog.create('Vui lòng đợi', 'Đang cập nhật', 'Đang tải...')
        items = getItems(path)
        total = len(items)
        i = 0
        failed = []
        for item in items:
            done = int(100 * i / total)
            pDialog.update(done, 'Đang tải', item["label2"] + '...')
            try:
                item["path"] = "http" + item["path"].split("http")[-1]
                download(urllib.unquote_plus(item["path"]), item["label2"])
            except:
                failed += [item["label"].encode("utf-8")]
            if pDialog.iscanceled():
                break
            i += 1
        pDialog.close()
        if len(failed) > 0:
            dlg = xbmcgui.Dialog()
            s = "Không thể cài các rep sau:\n[COLOR orange]%s[/COLOR]" % "\n".join(
                failed)
            dlg.ok('Chú ý: Không cài đủ repo!', s)
        else:
            dlg = xbmcgui.Dialog()
            s = "Đã cập nhật thành công"
            dlg.ok('Cập nhật xong!', s)

    else:  # cài repo riêng lẻ
        try:
            download(path, "")
            dlg = xbmcgui.Dialog()
            s = "Repo %s đã được cài thành công" % tracking_string
            dlg.ok('Cài Repo thành công!', s)
        except:
            dlg = xbmcgui.Dialog()
            s = "Vùi lòng thử cài lại lần sau"
            dlg.ok('Cài repo thất bại!', s)

    xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
    xbmc.executebuiltin("XBMC.UpdateAddonRepos()")
def action_prerun(link):
    #    xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)')
    if link.startswith("plugin://"):
        id = link.split("/")
        xbmc.executebuiltin('RunAddon(%s)' % id[2])
        while xbmc.getInfoLabel('Container.PluginName') != id[
                2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'):
            xbmc.sleep(250)
        xbmc.sleep(250)
        xbmc.executebuiltin('Container.Update("%s")' % link)
Beispiel #48
0
def mark_autostart(station_id):
    for station in my_stations.values():
        if 'autostart' in station:
            del station['autostart']

    if station_id in my_stations:
        station = my_stations[station_id]
        station['autostart'] = "true"
    my_stations.sync()
    xbmc.executebuiltin('Container.Refresh')
Beispiel #49
0
def search():
    return []
    keyboard = xbmc.Keyboard('', '请输入搜索内容')

    keyboard.doModal()
    if (keyboard.isConfirmed()):
        key = keyboard.getText()
        if len(key) > 0:
            u = sys.argv[0] + '?mode=searchlist&key=' + key
            xbmc.executebuiltin('Container.Update(%s)' % u)
Beispiel #50
0
def enMain():
	items = [
		{'label': 'My Audio Bible', 'path': plugin.url_for('listMyBible')},
		{'label': 'Wisdom and Songs of the Day', 'path': plugin.url_for('listWisdomAndSongs')},
		{'label': 'Audio Bible Browser', 'path': plugin.url_for('listRecordings')}
	]
	recording=plugin.get_setting("defaultrecording", unicode)
	if forceViewMode=="true":
		xbmc.executebuiltin('Container.SetViewMode('+viewMode+')')
	return plugin.finish(items)
Beispiel #51
0
 def background_task(self):
     xbmc.sleep(1000)
     while not xbmc.abortRequested and self.active:
         if self.hide_progress:
             active_window = xbmcgui.getCurrentWindowDialogId()
             if active_window in [10101,10151]:
                 xbmc.executebuiltin("Dialog.Close(%d, true)" % active_window)
         if self.hide_info:
             if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
                 xbmc.executebuiltin('Dialog.Close(infodialog, true)')                
         xbmc.sleep(100)
Beispiel #52
0
def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode == 'default' or mode == 'select': players = active_players("movies")
    else: players = get_players("movies")
    players = [p for p in players if p.id == play_plugin] or players
    if not players:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,videos")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
            tmdb_data = tmdb.Movies(tmdb_id).info(language=lang)
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        action_play({
            'label': movie_info['title'],
            'path': link,
            'info': movie_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': movie_info['poster'],
            'poster': movie_info['poster'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
Beispiel #53
0
def play_movie(tmdb_id, mode):
    import_tmdb()
    # Get players to use
    if mode == 'select':
        play_plugin = ADDON_SELECTOR.id
    elif mode == 'context':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, unicode)
    elif mode == 'library':
        play_plugin = get_movie_player_plugin_from_library(tmdb_id)
        if not play_plugin or play_plugin == "default":
            play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)
    elif mode == 'default':
        play_plugin = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER, unicode)
    else:
        play_plugin = mode
    if mode != 'context': players = active_players("movies")
    else: players = get_players("movies")
    players = [p for p in players if p.id == play_plugin] or players
    if not players or len(players) == 0:
        xbmc.executebuiltin( "Action(Info)")
        action_cancel()
        return
    # Get movie data from TMDB
    movie = tmdb.Movies(tmdb_id).info(language=LANG, append_to_response="external_ids,alternative_titles,credits,images,keywords,releases,videos,translations,similar,reviews,lists,rating")
    movie_info = get_movie_metadata(movie)
    # Get movie ids from Trakt
    trakt_ids = get_trakt_ids("tmdb", tmdb_id, movie['original_title'],
                    "movie", parse_year(movie['release_date']))
    # Get parameters
    params = {}
    for lang in get_needed_langs(players):
        if lang == LANG:
            tmdb_data = movie
        else:
                        tmdb_data = tmdb.Movies(tmdb_id).info(language=lang, append_to_response="external_ids,alternative_titles,credits,images,keywords,releases,videos,translations,similar,reviews,lists,rating")
        params[lang] = get_movie_parameters(tmdb_data)
        if trakt_ids != None:
            params[lang].update(trakt_ids)
        params[lang]['info'] = movie_info
        params[lang] = to_unicode(params[lang])
    # Go for it
    link = on_play_video(mode, players, params, trakt_ids)
    if link:
        movie = tmdb.Movies(tmdb_id).info(language=LANG)
        action_play({
            'label': movie_info['title'],
            'path': link,
            'info': movie_info,
            'is_playable': True,
            'info_type': 'video',
            'thumbnail': movie_info['poster'],
            'poster': movie_info['poster'],
            'properties' : {'fanart_image' : movie_info['fanart']},
        })
Beispiel #54
0
 def notify(self, msg='', title=None, delay=5000, image=''):
     '''Displays a temporary notification message to the user. If
     title is not provided, the plugin name will be used. To have a
     blank title, pass '' for the title argument. The delay argument
     is in milliseconds.
     '''
     if not msg:
         log.warning('Empty message for notification dialog')
     if title is None:
         title = self.addon.getAddonInfo('name')
     xbmc.executebuiltin('XBMC.Notification("%s", "%s", "%s", "%s")' %
                         (to_utf8(msg), to_utf8(title), delay, to_utf8(image)))
Beispiel #55
0
def main():
    go_idle(45)
    if plugin.get_setting(SETTING_TOTAL_SETUP_DONE, converter=bool) == False:
        xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/totalsetup/)")
        plugin.set_setting(SETTING_TOTAL_SETUP_DONE, "true")
    xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/batch_add_to_library)")
    next_update = future(0)
    while not xbmc.abortRequested:
        if next_update <= future(0):
            next_update = future(UPDATE_LIBRARY_INTERVAL)
            update_library()
        go_idle(30 * 60)
Beispiel #56
0
def showAllShows():
    url = 'http://geekandsundry.com/shows/'
    try:
        html = getPage(url)
    except:
        ERROR('Failed getting main page')
        xbmc.executebuiltin('Notification(%s,%s,%s,%s)' % ('Geek & Sundry',T(32101),3,plugin.addon.getAddonInfo('icon')))  # @UndefinedVariable #For xbmcswift2
        return

    items = []

    soup = getSoup(html)
    div = soup.select('div.shelf')
    if not div: return
    anchors = div[0].findAll('a')
    import xbmcgui
    first = True
    donePath = os.path.join(FANART_PATH,'done')
    if os.path.exists(donePath): first = False
    with open(donePath,'w') as f: f.write(str(time.time()))
    if first:
        d = xbmcgui.DialogProgress()
        d.create('Loading shows','Initializing...')
    total = len(anchors)
    for i, a in enumerate(anchors):
        try:
            title = convertHTMLCodes(a.findAll(text=True)[0])
        except:
            ERROR('Failed to get show title')
            continue

        surl = a.get('href')
        if first:
            if d.iscanceled(): break
            d.update(int((i/float(total))*100),'Initializing:',title)
        fanart, icon = getShowIcon(surl)
        status = ''
#        statusdisp = status
#        if 'Air' in status:
#            statusdisp = '[COLOR green]{0}[/COLOR]'.format(status)
#        elif 'Hiatus' in status:
#            statusdisp = '[COLOR FFAAAA00]{0}[/COLOR]'.format(status)
#        plot = '{0}: [B]{1}[/B][CR][CR]{2}'.format(T(32102),statusdisp,idict.get('desc'))
        mode = 'showShow'
        items.append(   {   'label':title,
                            'path':plugin.url_for(mode,url=surl),
                            'icon':icon,
                            'properties':{'fanart_image':fanart},
                            'info':{'Plot':'','status':status}
                        }
        )

    return items
Beispiel #57
0
 def background_task(self):
     xbmc.sleep(1000)
     while not xbmc.abortRequested and self.active:
         if self.hide_progress:
             active_window = xbmcgui.getCurrentWindowDialogId()
             if active_window in [10101, 10151]:
                 xbmc.executebuiltin("Dialog.Close(%d, true)" %
                                     active_window)
         if self.hide_info:
             if xbmc.getCondVisibility("Window.IsActive(infodialog)"):
                 xbmc.executebuiltin('Dialog.Close(infodialog, true)')
         xbmc.sleep(100)
def RemovePlaylists(item=""):
	item = urllib.unquote_plus(item)
	if item is not "":
		playlists = plugin.get_storage('playlists')
		if 'sections' in playlists:
			new_playlists = []
			for section in playlists["sections"]:
				if section != item:
					new_playlists += [section]
			playlists["sections"] = new_playlists
	else:
		plugin.get_storage('playlists').clear()
	xbmc.executebuiltin('Container.Refresh')
Beispiel #59
0
    def do_update(self, update):
        file_path = update.file_path
        with open(file_path, 'wb') as asset:
            asset.write(urllib2.urlopen(update.asset_url).read())
            asset.close()
        zip_file = zipfile.ZipFile(file_path)
        zip_file.extractall(xbmcaddon.Addon().getAddonInfo('path'), self._get_members(zip_file))

        xbmcgui.Dialog().ok(
            self.core.string('name'),
            'Luna has been updated to version %s and will now relaunch.' % update.update_version
        )

        xbmc.executebuiltin('RunPlugin(\'script.luna\')')
def create_lostfilm_source():
    from support.sources import Sources, TvDbScraperSettings, SourceAlreadyExists
    sources = Sources()
    plugin.log.info("Creating LostFilm.TV source...")
    try:
        sources.add_video(plugin.get_setting('library-path', unicode), 'LostFilm.TV', TvDbScraperSettings())
    except SourceAlreadyExists:
        plugin.set_setting('lostfilm-source-created', True)
        raise LocalizedError(40408, "Source is already exist")
    plugin.log.info("LostFilm.TV source created, restart needed...")
    plugin.set_setting('lostfilm-source-created', True)
    d = xbmcgui.Dialog()
    if d.yesno(lang(40404), lang(40405)):
        xbmc.executebuiltin('Quit')