コード例 #1
0
    def listdir(self, path):

        try:
            return xbmcvfs.listdir(path)
        except:
            file_list = []
            dir_list = []
            json_response = xbmc.executeJSONRPC(
                '{ "jsonrpc" : "2.0" , "method" : "Files.GetDirectory" , "params" : { "directory" : "%s" , "sort" : { "method" : "file" } } , "id" : 1 }'
                % common.smart_utf8(path.replace('\\', '\\\\')))
            jsonobject = json.loads(json_response)

            try:
                if jsonobject['result']['files']:

                    for item in jsonobject['result']['files']:

                        filename = common.smart_utf8(item['label'])
                        if item['filetype'] == 'directory':
                            dir_list.append(filename)
                        else:
                            file_list.append(filename)

            except Exception, msg:
                common.log("Scanner.listdir", 'Path "%s"' % path,
                           xbmc.LOGERROR)
                common.log("Scanner.listdir", "%s - %s" % (Exception, msg),
                           xbmc.LOGERROR)

            return dir_list, file_list
コード例 #2
0
def convert_subtitles(closedcaption):
    str_output = ''
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data,
                                  'html.parser',
                                  parse_only=SoupStrainer('div'))
    lines = subtitle_data.find_all('p')
    for i, line in enumerate(lines):
        if line is not None:
            sub = clean_subs(common.smart_utf8(line))
            start_time_rest, start_time_msec = line['begin'].rsplit(':', 1)
            start_time = common.smart_utf8(start_time_rest + ',' +
                                           start_time_msec)
            try:
                end_time_rest, end_time_msec = line['end'].rsplit(':', 1)
                end_time = common.smart_utf8(end_time_rest + ',' +
                                             end_time_msec)
            except:
                continue
            str_output += str(
                i + 1
            ) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
    file = open(ustvpaths.SUBTITLE, 'w')
    file.write(str_output)
    file.close()
コード例 #3
0
def convert_subtitles(closedcaption):
    str_output = ""
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data, "html.parser", parse_only=SoupStrainer("div"))
    srt_output = ""
    lines = subtitle_data.find_all("p")
    i = 0
    last_start_time = ""
    last_end_time = ""
    for line in lines:
        try:
            if line is not None:
                sub = clean_subs(common.smart_utf8(line))
                start_time = common.smart_utf8(line["begin"].replace(".", ","))
                end_time = common.smart_utf8(line["end"].replace(".", ","))
                if start_time != last_start_time and end_time != last_end_time:
                    str_output += "\n" + str(i + 1) + "\n" + start_time + " --> " + end_time + "\n" + sub + "\n"
                    i = i + 1
                    last_end_time = end_time
                    last_start_time = start_time
                else:
                    str_output += sub + "\n\n"
        except:
            pass
    file = open(ustvpaths.SUBTITLE, "w")
    file.write(str_output)
    file.close()
    return True
コード例 #4
0
ファイル: nbc.py プロジェクト: MarkTV/MarkTV
def convert_subtitles(closedcaption):
	str_output = ''
	subtitle_data = connection.getURL(closedcaption, connectiontype = 0)
	subtitle_data = BeautifulSoup(subtitle_data, 'html.parser', parse_only = SoupStrainer('div'))
	srt_output = ''
	lines = subtitle_data.find_all('p')
	i = 0
	last_start_time = ''
	last_end_time = ''
	for line in lines:
		try:
			if line is not None:
				sub = clean_subs(common.smart_utf8(line))
				start_time = common.smart_utf8(line['begin'].replace('.', ','))
				end_time = common.smart_utf8(line['end'].replace('.', ','))
				if start_time != last_start_time and end_time != last_end_time:
					str_output += '\n' + str(i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n'
					i = i + 1
					last_end_time = end_time
					last_start_time = start_time
				else:
					str_output +=  sub + '\n\n'
		except:
			pass
	file = open(ustvpaths.SUBTITLE, 'w')
	file.write(str_output)
	file.close()
コード例 #5
0
def convert_subtitles(closedcaption):
	str_output = ''
	j = 0
	count = 0
	for closedcaption_url, duration, i in closedcaption:
		count = int(i) + 1
		if closedcaption_url is not None:
			subtitle_data = connection.getURL(closedcaption_url['src'], connectiontype = 0)
			subtitle_data = BeautifulSoup(subtitle_data, 'html.parser', parse_only = SoupStrainer('div'))
			lines = subtitle_data.find_all('p')
			last_line = lines[-1]
			end_time = last_line['end'].split('.')[0].split(':')
			file_duration = int(end_time[0]) * 60 * 60 + int(end_time[1]) * 60 + int(end_time[2])
			delay = int(file_duration) - int(duration)
			for i, line in enumerate(lines):
				if line is not None:
					try:
						sub = clean_subs(common.smart_utf8(line))
						start_time = common.smart_utf8(datetime.datetime.strftime(datetime.datetime.strptime(line['begin'], '%H:%M:%S.%f') - datetime.timedelta(seconds = int(delay)),'%H:%M:%S,%f'))[:-4]
						end_time = common.smart_utf8(datetime.datetime.strftime(datetime.datetime.strptime(line['end'], '%H:%M:%S.%f') - datetime.timedelta(seconds = int(delay)),'%H:%M:%S,%f'))[:-4]
						str_output += str(j + i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
					except:
						pass
			j = j + i + 1
			file = open(os.path.join(ustvpaths.DATAPATH, 'subtitle-%s.srt' % str(count)), 'w')
			file.write(str_output)
			str_output=''
			file.close()
コード例 #6
0
ファイル: fox.py プロジェクト: zymbiosis/plugin.video.ustvvod
def convert_subtitles(closedcaption):
    str_output = ''
    last_start_time = ''
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data,
                                  'html.parser',
                                  parse_only=SoupStrainer('div'))
    lines = subtitle_data.find_all('p')
    for i, line in enumerate(lines):
        if line is not None:
            sub = clean_subs(common.smart_utf8(line))
            start_time = common.smart_utf8(line['begin'].replace('.', ','))
            try:
                end_time = common.smart_utf8(line['end'].replace('.', ','))
            except:
                continue
            if last_start_time != start_time:
                if i != 0:
                    str_output += '\n\n'
                str_output += str(
                    i +
                    1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub
            else:
                str_output += '\n' + sub
            last_start_time = start_time
    file = open(ustvpaths.SUBTITLE, 'w')
    file.write(str_output)
    file.close()
コード例 #7
0
def convert_subtitles(closedcaption):
	str_output = ''
	j = 0
	count = 0
	for closedcaption_url, duration, i in closedcaption:
		count = int(i) + 1
		if closedcaption_url is not None:
			subtitle_data = connection.getURL(closedcaption_url['src'], connectiontype = 0)
			subtitle_data = BeautifulSoup(subtitle_data, 'html.parser', parse_only = SoupStrainer('div'))
			lines = subtitle_data.find_all('p')
			last_line = lines[-1]
			end_time = last_line['end'].split('.')[0].split(':')
			file_duration = int(end_time[0]) * 60 * 60 + int(end_time[1]) * 60 + int(end_time[2])
			delay = int(file_duration) - int(duration)
			for i, line in enumerate(lines):
				if line is not None:
					try:
						sub = clean_subs(common.smart_utf8(line))
						start_time = common.smart_utf8(datetime.datetime.strftime(datetime.datetime.strptime(line['begin'], '%H:%M:%S.%f') - datetime.timedelta(seconds = int(delay)),'%H:%M:%S,%f'))[:-4]
						end_time = common.smart_utf8(datetime.datetime.strftime(datetime.datetime.strptime(line['end'], '%H:%M:%S.%f') - datetime.timedelta(seconds = int(delay)),'%H:%M:%S,%f'))[:-4]
						str_output += str(j + i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
					except:
						pass
			j = j + i + 1
			file = open(os.path.join(ustvpaths.DATAPATH, 'subtitle-%s.srt' % str(count)), 'w')
			file.write(str_output)
			str_output=''
			file.close()
コード例 #8
0
def convert_subtitles(closedcaption):
    str_output = ''
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data,
                                  'html.parser',
                                  parse_only=SoupStrainer('div'))
    srt_output = ''
    lines = subtitle_data.find_all('p')
    i = 0
    last_start_time = ''
    last_end_time = ''
    for line in lines:
        try:
            if line is not None:
                sub = clean_subs(common.smart_utf8(line))
                start_time = common.smart_utf8(line['begin'].replace('.', ','))
                end_time = common.smart_utf8(line['end'].replace('.', ','))
                if start_time != last_start_time and end_time != last_end_time:
                    str_output += '\n' + str(
                        i + 1
                    ) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n'
                    i = i + 1
                    last_end_time = end_time
                    last_start_time = start_time
                else:
                    str_output += sub + '\n\n'
        except:
            pass
    file = open(ustvpaths.SUBTITLE, 'w')
    file.write(str_output)
    file.close()
    return True
コード例 #9
0
def convert_subtitles(closedcaption):
    str_output = ''
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data,
                                  'html.parser',
                                  parse_only=SoupStrainer('div'))
    lines = subtitle_data.find_all('p')
    for i, line in enumerate(lines):
        if line is not None:
            sub = clean_subs(common.smart_utf8(line))
            start_time_hours, start_time_rest = line['begin'].split(':', 1)
            start_time_hours = '%02d' % (int(start_time_hours) - 1)
            start_time = common.smart_utf8(start_time_hours + ':' +
                                           start_time_rest.replace('.', ','))
            end_time_hours, end_time_rest = line['end'].split(':', 1)
            end_time_hours = '%02d' % (int(end_time_hours) - 1)
            end_time = common.smart_utf8(end_time_hours + ':' +
                                         end_time_rest.replace('.', ','))
            str_output += str(
                i + 1
            ) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
    file = open(ustvpaths.SUBTITLE, 'w')
    file.write(str_output)
    file.close()
    return True
コード例 #10
0
    def listdir(self, path):

        try:
            return xbmcvfs.listdir(path)
        except:
            file_list = []
            dir_list = []
            json_response = xbmc.executeJSONRPC(
                '{ "jsonrpc" : "2.0" , "method" : "Files.GetDirectory" , "params" : { "directory" : "%s" , "sort" : { "method" : "file" } } , "id" : 1 }'
                % common.smart_utf8(path.replace("\\", "\\\\"))
            )
            jsonobject = json.loads(json_response)

            try:
                if jsonobject["result"]["files"]:

                    for item in jsonobject["result"]["files"]:

                        filename = common.smart_utf8(item["label"])
                        if item["filetype"] == "directory":
                            dir_list.append(filename)
                        else:
                            file_list.append(filename)

            except Exception, msg:
                common.log("Scanner.listdir", 'Path "%s"' % path, xbmc.LOGERROR)
                common.log("Scanner.listdir", "%s - %s" % (Exception, msg), xbmc.LOGERROR)

            return dir_list, file_list
コード例 #11
0
ファイル: addon.py プロジェクト: MossyTC/plugin.video.ustvvod
def modes():
	if sys.argv[2] == '':
		all_description = ''
		networks = common.get_networks()
		networks.sort(key = lambda x: x.SITE.replace('the', ''))
		for network in networks:
			if addon.getSetting(network.SITE) == 'true':
				if network.NAME.endswith(', The'):
					name = 'The ' + network.NAME.replace(', The', '')
				all_description += network.NAME + ', '
		count = 0
		common.add_directory(common.smart_utf8(addon.getLocalizedString(39000)), 'Favorlist', 'NoUrl', thumb = ustvpaths.FAVICON, count = count, description = common.smart_utf8(addon.getLocalizedString(39001)) + '\n' + all_description)
		count += 1
		common.add_directory(common.smart_utf8(addon.getLocalizedString(39002)), 'Masterlist', 'NoUrl', thumb = ustvpaths.ALLICON, count = count, description = common.smart_utf8(addon.getLocalizedString(39003)) + '\n' + all_description)
		count += 1
		for network in networks:
			network_name = network.NAME
			station_icon = os.path.join(ustvpaths.IMAGEPATH, network.SITE + '.png')
			if network_name.endswith(', The'):
				network_name = 'The ' + network_name.replace(', The', '')
			if addon.getSetting(network.SITE) == 'true':
				common.add_directory(network_name, network.SITE, 'rootlist', thumb = station_icon, fanart = ustvpaths.PLUGINFANART, description = network.DESCRIPTION, count = count)
			count += 1
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_PLAYLIST_ORDER)
		common.set_view()
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode == 'Masterlist':
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.load_showlist()
		common.set_view('tvshows')
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.sitemode == 'rootlist':
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.root_list(common.args.mode)
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode == 'Favorlist':   
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.load_showlist(favored = 1)
		common.set_view('tvshows')
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode == 'contextmenu':
		getattr(contextmenu, common.args.sitemode)()
	elif common.args.mode == 'common':
		getattr(common, common.args.sitemode)()
	else:
		network = common.get_network(common.args.mode)
		if network:
			getattr(network, common.args.sitemode)()
			if 'episodes' in  common.args.sitemode and addon.getSetting('add_episode_identifier') == 'false':
				try:
					xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_DATEADDED)
				except:
					pass
				xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_EPISODE)
				xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_UNSORTED)
			if not common.args.sitemode.startswith('play'):
				xbmcplugin.endOfDirectory(pluginHandle)
コード例 #12
0
ファイル: crackle.py プロジェクト: MarkTV/MarkTV
def convert_subtitles(closedcaption):
	str_output = ''
	subtitle_data = connection.getURL(closedcaption, connectiontype = 0)
	subtitle_data = BeautifulSoup(subtitle_data, 'html.parser', parse_only = SoupStrainer('div'))
	srt_output = ''
	lines = subtitle_data.find_all('p')
	for i, line in enumerate(lines):
		if line is not None:
			sub = clean_subs(common.smart_utf8(line))
			start_time = common.smart_utf8(line['begin'].replace('.', ','))
			end_time = common.smart_utf8(line['end'].replace('.', ','))
			str_output += str(i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
	file = open(ustvpaths.SUBTITLE, 'w')
	file.write(str_output)
	file.close()
コード例 #13
0
ファイル: cbs.py プロジェクト: rshyffer/plugin.video.ustvvod
def convert_subtitles(closedcaption):
    str_output = ""
    subtitle_data = connection.getURL(closedcaption, connectiontype=0)
    subtitle_data = BeautifulSoup(subtitle_data, "html.parser", parse_only=SoupStrainer("div"))
    srt_output = ""
    lines = subtitle_data.find_all("p")
    for i, line in enumerate(lines):
        if line is not None:
            sub = clean_subs(common.smart_utf8(line))
            start_time = common.smart_utf8(line["begin"].replace(".", ","))
            end_time = common.smart_utf8(line["end"].replace(".", ","))
            str_output += str(i + 1) + "\n" + start_time + " --> " + end_time + "\n" + sub + "\n\n"
    file = open(ustvpaths.SUBTITLE, "w")
    file.write(str_output)
    file.close()
コード例 #14
0
def convert_subtitles(closedcaption):
	str_output = ''
	subtitle_data = connection.getURL(closedcaption, connectiontype = 0)
	subtitle_data = clean_subs(common.smart_utf8(subtitle_data))
	file = open(ustvpaths.SUBTITLESMI, 'w')
	file.write(subtitle_data)
	file.close()
コード例 #15
0
ファイル: cartoon.py プロジェクト: MarkTV/MarkTV
def masterlist():
	master_db = []
	master_dict = {}
	master_data = connection.getURL(SHOWS)
	master_tree = BeautifulSoup(master_data, 'html.parser')
	master_menu = master_tree.allcollections.find_all('collection')
	for master_item in master_menu:
		master_name = common.smart_utf8(master_item['name'])
		if '[AD]' not in master_name and 'Unlocked' not in master_name:
			tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
			season_url = master_item['id'] 
			season_url = season_url + '#tveepisodes='
			try:
				for season in master_item.tveepisodes.find_all('season'):
					season_url = season_url + '-' + season['number']
			except:
				pass
			season_url = season_url + '#clips='
			try:
				for season in master_item.clips.find_all('season'):
					if season['number'] != '':
						season_url = season_url + '-' + season['number']
				else:
					season_url = season_url + '-' + '*'
			except:
				pass
			master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db
コード例 #16
0
    def onAction(self, action):
        # Cancel
        if (action.getId() in CANCEL_DIALOG
                or self.getFocusId() == BUTTON_CANCEL
                and action.getId() in SELECT_ITEM):
            self.close()
        # Okay
        if (self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM):
            self.close()

        # Select or deselect item in list
        if (action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST):
            item = self.getControl(TAGS_LIST).getSelectedItem()
            #pos  = self.getControl( TAGS_LIST ).getSelectedPosition()

            kb = xbmc.Keyboard(
                item.getLabel2(),
                common.getstring(30623) % (common.smart_utf8(item.getLabel())),
                False)
            kb.doModal()
            if (kb.isConfirmed()):
                item.setLabel2(kb.getText())
                self.MPDB.set_tagtype_translation(
                    common.smart_unicode(item.getLabel()),
                    common.smart_unicode(item.getLabel2()))
                self.getControl(TAGS_LIST).setVisible(False)
                self.getControl(TAGS_LIST).setVisible(True)
コード例 #17
0
ファイル: pbs.py プロジェクト: MossyTC/plugin.video.ustvvod
def masterlist():
	master_start = 0
	master_count = 200
	master_db = []
	master_dict = {}
	master_check = []
	master_menu = simplejson.loads(connection.getURL(SHOWS, header = {'X-Requested-With' : 'XMLHttpRequest'}))
	for master_item in master_menu.itervalues():
		for master_item in master_item:
			master_check.append(master_item['title'])
	while master_start < master_count:
		master_data = cove.programs.filter(fields = 'mediafiles', order_by = 'title', limit_start = master_start)
		master_menu = master_data['results']
		master_count = master_data['count']
		master_stop = master_data['stop']
		del master_data
		for master_item2 in master_menu:
			website = master_item2['website']
			if website is None:
				website = ''
			if master_item2['title'] in master_check and ('PBS Kids' !=  master_item2['nola_root']) and ('blog' not in website):
				master_name = common.smart_utf8(master_item2['title'])
				tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
				season_url = re.compile('/cove/v1/programs/(.*?)/').findall(master_item2['resource_uri'])[0]
				if tvdb_name not in master_dict.keys():
					master_dict[tvdb_name] = common.smart_unicode(master_name) + '#' +season_url
				else:
					master_dict[tvdb_name] = master_dict[tvdb_name] + ',' + master_name + '#' + season_url
		master_start = master_stop
	for master_name in master_dict:
		season_url = master_dict[master_name]
		master_db.append((master_name, SITE, 'seasons', season_url))
	return master_db
コード例 #18
0
def masterlist():
	master_db = []
	master_menu = simplejson.loads(connection.getURL(SHOWS))
	for master_item in master_menu['items']:
		master_name = common.smart_utf8(master_item['title'])
		master_db.append((master_name, SITE, 'seasons', urllib.quote_plus(master_name)))
	return master_db
コード例 #19
0
def seasons(SITE, FULLEPISODES, CLIPSSEASON, CLIPS, WEBSHOWS = None, show_id = common.args.url):
	seasons = []
	master_name = show_id.split('#')[0]
	has_full_eps = show_id.split('#')[2]
	show_id = show_id.split('#')[1]
	if has_full_eps == 'true':
		seasons.append(('Full Episodes',  SITE, 'episodes', master_name + '#' + FULLEPISODES % show_id, -1, -1))
	elif WEBSHOWS is not None:
		try:

			webdata = connection.getURL(WEBSHOWS)
			web_tree =  BeautifulSoup(webdata, 'html.parser', parse_only = SoupStrainer('div', id = 'page-shows'))
			show = web_tree.find(text = master_name)
			print web_tree
			episodes = show.findNext('p', attrs = {'data-id' : 'num-full-eps-avail'})['data-value']
			if int(episodes) > 0:
				seasons.append(('Full Episodes',  SITE, 'episodes_web', master_name, -1, -1))
		except:
			pass

	clips_data = connection.getURL(CLIPSSEASON % show_id)
	clips_menu = simplejson.loads(clips_data)
	for season in clips_menu:
		clip_name = common.smart_utf8(season['title'])
		seasons.append((clip_name,  SITE, 'episodes', master_name + '#' + CLIPS % (show_id, season['id']), -1, -1))

	return seasons
コード例 #20
0
ファイル: main_turner.py プロジェクト: MarkTV/MarkTV
def seasons(SITE, FULLEPISODES, CLIPSSEASON, CLIPS, WEBSHOWS = None, show_id = common.args.url):
	seasons = []
	master_name = show_id.split('#')[0]
	has_full_eps = show_id.split('#')[2]
	show_id = show_id.split('#')[1]
	if has_full_eps == 'true':
		seasons.append(('Full Episodes',  SITE, 'episodes', master_name + '#' + FULLEPISODES % show_id, -1, -1))
	elif WEBSHOWS is not None:
		try:

			webdata = connection.getURL(WEBSHOWS)
			web_tree =  BeautifulSoup(webdata, 'html.parser', parse_only = SoupStrainer('div', id = 'page-shows'))
			show = web_tree.find('h2', text = master_name)
			episodes = show.findNext('p', attrs = {'data-id' : 'num-full-eps-avail'})['data-value']
			if int(episodes) > 0:
				seasons.append(('Full Episodes',  SITE, 'episodes_web', master_name, -1, -1))
		except:
			pass

	clips_data = connection.getURL(CLIPSSEASON % show_id)
	clips_menu = simplejson.loads(clips_data)
	for season in clips_menu:
		clip_name = common.smart_utf8(season['title'])
		seasons.append((clip_name,  SITE, 'episodes', master_name + '#' + CLIPS % (show_id, season['id']), -1, -1))

	return seasons
コード例 #21
0
def masterlist():
    master_db = []
    master_dict = {}
    master_data = connection.getURL(SHOWS)
    master_tree = BeautifulSoup(master_data, 'html.parser')
    master_menu = master_tree.allcollections.find_all('collection')
    for master_item in master_menu:
        master_name = common.smart_utf8(master_item['name'])
        if '[AD]' not in master_name and 'Unlocked' not in master_name:
            tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
            season_url = master_item['id']
            season_url = season_url + '#tveepisodes='
            try:
                for season in master_item.tveepisodes.find_all('season'):
                    season_url = season_url + '-' + season['number']
            except:
                pass
            season_url = season_url + '#clips='
            try:
                for season in master_item.clips.find_all('season'):
                    if season['number'] != '':
                        season_url = season_url + '-' + season['number']
                else:
                    season_url = season_url + '-' + '*'
            except:
                pass
            master_db.append((master_name, SITE, 'seasons', season_url))
    return master_db
コード例 #22
0
def convert_subtitles(closedcaption):
    str_output = ''
    count = 0
    for closedcaption_url, i in closedcaption:
        count = int(i) + 1
        if closedcaption_url is not None:
            try:
                cc_content = common.smart_unicode(
                    connection.getURL(closedcaption_url,
                                      connectiontype=0).replace(' 9137', ''))
                reader = detect_format(cc_content)
                if reader:

                    str_output = common.smart_utf8(SRTWriter().write(
                        reader().read(cc_content)))
                    file = open(
                        os.path.join(ustvpaths.DATAPATH,
                                     'subtitle-%s.srt' % str(count)), 'w')
                    file.write(str_output)
                    str_output = ''
                    file.close()
                else:
                    print "Unknown sub type"
            except Exception, e:
                print "Exception with Subs: ", e
コード例 #23
0
def convert_subtitles(video_guid):
	try:
		file = None
		dialog = xbmcgui.DialogProgress()
        	dialog.create(common.smart_utf8(addon.getLocalizedString(39026)))
		dialog.update(0, common.smart_utf8(addon.getLocalizedString(39027)))
		str_output = ''
		subtitle_data = connection.getURL(CLOSEDCAPTION % video_guid, connectiontype = 0)
		subtitle_data = simplejson.loads(subtitle_data)
		lines_total = len(subtitle_data)
		dialog.update(0, common.smart_utf8(addon.getLocalizedString(39028)))
		for i, subtitle_line in enumerate(subtitle_data):
			if subtitle_line is not None and 'Text' in subtitle_line['metadata']:
				if (dialog.iscanceled()):
					return
				if i % 10 == 0:
					percent = int( (float(i*100) / lines_total) )
					dialog.update(percent, common.smart_utf8(addon.getLocalizedString(30929)))
				sub = common.smart_utf8(subtitle_line['metadata']['Text'])
				start_time = common.smart_utf8(str(subtitle_line['startTime'])).split('.')
				start_minutes, start_seconds = divmod(int(start_time[0]), 60)
				start_hours, start_minutes = divmod(start_minutes, 60)
				start_time = '%02d:%02d:%02d,%02d' % (start_hours, start_minutes, start_seconds, int(start_time[1][0:2]))
				end_time = common.smart_utf8(str(subtitle_line['endTime'])).split('.')
				end_minutes, end_seconds = divmod(int(end_time[0]), 60)
				end_hours, end_minutes = divmod(end_minutes, 60)
				end_time = '%02d:%02d:%02d,%02d' % (end_hours, end_minutes, end_seconds, int(end_time[1][0:2]))
				str_output += str(i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
		file = open(ustvpaths.SUBTITLE, 'w')
		file.write(str_output)
		file.close()
	except Exception, e:
		print "Exception: " + unicode(e)
		common.show_exception(NAME, addon.getLocalizedString(39030))
コード例 #24
0
ファイル: thecw.py プロジェクト: MossyTC/plugin.video.ustvvod
def convert_subtitles(video_guid):
	try:
		file = None
		dialog = xbmcgui.DialogProgress()
        	dialog.create(common.smart_utf8(xbmcaddon.Addon(id = common.ADDONID).getLocalizedString(39026)))
		dialog.update(0, common.smart_utf8(xbmcaddon.Addon(id = common.ADDONID).getLocalizedString(39027)))
		str_output = ''
		subtitle_data = connection.getURL(CLOSEDCAPTION % video_guid, connectiontype = 0)
		subtitle_data = simplejson.loads(subtitle_data)
		lines_total = len(subtitle_data)
		dialog.update(0, common.smart_utf8(xbmcaddon.Addon(id = common.ADDONID).getLocalizedString(39028)))
		for i, subtitle_line in enumerate(subtitle_data):
			if subtitle_line is not None and 'Text' in subtitle_line['metadata']:
				if (dialog.iscanceled()):
					return
				if i % 10 == 0:
					percent = int( (float(i*100) / lines_total) )
					dialog.update(percent, common.smart_utf8(xbmcaddon.Addon(id = common.ADDONID).getLocalizedString(30929)))
				sub = common.smart_utf8(subtitle_line['metadata']['Text'])
				start_time = common.smart_utf8(str(subtitle_line['startTime'])).split('.')
				start_minutes, start_seconds = divmod(int(start_time[0]), 60)
				start_hours, start_minutes = divmod(start_minutes, 60)
				start_time = '%02d:%02d:%02d,%02d' % (start_hours, start_minutes, start_seconds, int(start_time[1][0:2]))
				end_time = common.smart_utf8(str(subtitle_line['endTime'])).split('.')
				end_minutes, end_seconds = divmod(int(end_time[0]), 60)
				end_hours, end_minutes = divmod(end_minutes, 60)
				end_time = '%02d:%02d:%02d,%02d' % (end_hours, end_minutes, end_seconds, int(end_time[1][0:2]))
				str_output += str(i + 1) + '\n' + start_time + ' --> ' + end_time + '\n' + sub + '\n\n'
		file = open(ustvpaths.SUBTITLE, 'w')
		file.write(str_output)
		file.close()
	except Exception, e:
		print "Exception: " + unicode(e)
		common.show_exception(NAME, xbmcaddon.Addon(id = common.ADDONID).getLocalizedString(39030))
コード例 #25
0
def masterlist(SITE, SHOWS):
	master_db = []
	master_data = connection.getURL(SHOWS)
	master_tree = simplejson.loads(master_data)
	for master_item in master_tree:
		if (master_item['hasNoVideo'] == 'false'):
			master_name = common.smart_utf8(master_item['detailTitle'])
			master_db.append((master_name, SITE, 'seasons', urllib.quote_plus(master_item['showID'])))
	return master_db
コード例 #26
0
def masterlist(SITE, SHOWS):
    master_db = []
    master_data = connection.getURL(SHOWS)
    master_tree = simplejson.loads(master_data)
    for master_item in master_tree:
        if (master_item['hasNoVideo'] == 'false'):
            master_name = common.smart_utf8(master_item['detailTitle'])
            master_db.append((master_name, SITE, 'seasons',
                              urllib.quote_plus(master_item['showID'])))
    return master_db
コード例 #27
0
ファイル: pbs.py プロジェクト: jblasius/plugin.video.ustvvod
def masterlist():
    master_start = 0
    master_count = 200
    master_db = []
    master_dict = {}
    master_check = []
    master_menu = simplejson.loads(
        connection.getURL(SHOWS, header={'X-Requested-With':
                                         'XMLHttpRequest'}))
    for master_item in master_menu.itervalues():
        for master_item in master_item:
            master_check.append(master_item['title'])
    while master_start < master_count:
        master_data = cove.programs.filter(fields='mediafiles',
                                           order_by='title',
                                           limit_start=master_start)
        master_menu = master_data['results']
        master_count = master_data['count']
        master_stop = master_data['stop']
        del master_data
        for master_item2 in master_menu:
            website = master_item2['website']
            if website is None:
                website = ''
            if master_item2['title'] in master_check and (
                    'PBS Kids' !=
                    master_item2['nola_root']) and ('blog' not in website):
                master_name = common.smart_utf8(master_item2['title'])
                season_url = re.compile('/cove/v1/programs/(.*?)/').findall(
                    master_item2['resource_uri'])[0]
                tvdb_name = common.get_show_data(
                    master_name, SITE, 'seasons',
                    common.smart_unicode(master_name) + '#' + season_url)[-1]
                if season_url:
                    if tvdb_name not in master_dict.keys():
                        try:
                            master_dict[tvdb_name] = common.smart_unicode(
                                master_name) + '#' + season_url
                        except Exception, e:
                            print "e1", e
                            return e
                    else:
                        try:
                            master_dict[tvdb_name] = master_dict[
                                tvdb_name] + '|' + common.smart_unicode(
                                    master_name) + '#' + season_url
                        except Exception, e:
                            print "error", e
                            return e
                else:
                    print "No season"
コード例 #28
0
def masterlist(NAME, MOVIES, SHOWS, SITE, WEBSHOWS = None ):
	master_db = []
	master_dict = {}
	master_db.append(('--' + NAME + ' Movies',  SITE, 'episodes', 'Movie#' + MOVIES))
	master_data = connection.getURL(SHOWS)
	master_menu = simplejson.loads(master_data)
	for master_item in master_menu:
		master_name = common.smart_utf8(master_item['title'])
		if 'ondemandEpisodes' in master_item['excludedSections']:
			has_full_eps = 'false'
		else:
			has_full_eps = 'true'
		if (getSetting('hide_clip_only') == 'false' and 'clips' not in master_item['excludedSections']) or has_full_eps == 'true' or WEBSHOWS is not None:
			season_url = master_name + '#' + master_item['ID'] + '#' + has_full_eps
			master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db
コード例 #29
0
ファイル: main_turner.py プロジェクト: MarkTV/MarkTV
def masterlist(NAME, MOVIES, SHOWS, SITE, WEBSHOWS = None ):
	master_db = []
	master_dict = {}
	master_db.append(('--' + NAME + ' Movies',  SITE, 'episodes', 'Movie#' + MOVIES))
	master_data = connection.getURL(SHOWS)
	master_menu = simplejson.loads(master_data)
	for master_item in master_menu:
		master_name = common.smart_utf8(master_item['title'])
		if 'ondemandEpisodes' in master_item['excludedSections']:
			has_full_eps = 'false'
		else:
			has_full_eps = 'true'
		if (getSetting('hide_clip_only') == 'false' and 'clips' not in master_item['excludedSections']) or has_full_eps == 'true' or WEBSHOWS is not None:
			season_url = master_name + '#' + master_item['ID'] + '#' + has_full_eps
			master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db
コード例 #30
0
def masterlist():
	master_db = []
	master_dict = {}
	master_data = connection.getURL(SHOWS)
	master_tree = plistlib.readPlistFromString(master_data)
	for master_item in master_tree:
		master_name = common.smart_utf8(master_item['name'])
		tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
		if tvdb_name not in master_dict.keys():
			master_dict[tvdb_name] = master_item['show-id']
		else:
			master_dict[tvdb_name] = master_dict[tvdb_name] + ',' + master_item['show-id']
	for master_name in master_dict:
		season_url = master_dict[master_name]
		master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db
コード例 #31
0
def masterlist():
	master_db = []
	master_dict = {}
	master_data = connection.getURL(SHOWS)
	master_tree = plistlib.readPlistFromString(master_data)
	for master_item in master_tree:
		master_name = common.smart_utf8(master_item['name'])
		tvdb_name = common.get_show_data(master_name, SITE, 'seasons')[-1]
		if tvdb_name not in master_dict.keys():
			master_dict[tvdb_name] = master_item['show-id']
		else:
			master_dict[tvdb_name] = master_dict[tvdb_name] + ',' + master_item['show-id']
	for master_name in master_dict:
		season_url = master_dict[master_name]
		master_db.append((master_name,  SITE, 'seasons', season_url))
	return master_db
コード例 #32
0
    def getlocalfile(self, filename):

        filename = common.smart_unicode(filename)

        # Windows NEEDS unicode but OpenElec utf-8
        try:
            exists = os.path.exists(filename)
        except:
            exists = os.path.exists(common.smart_utf8(filename))
        if exists:
            return filename, False
        else:
            tempdir = xbmc.translatePath('special://temp').decode('utf-8')
            basefilename = self.getname(filename)
            destination = os.path.join(tempdir, basefilename)
            xbmcvfs.copy(filename, destination)

            return common.smart_unicode(destination), True
コード例 #33
0
    def getlocalfile(self, filename):

        filename = common.smart_unicode(filename)

        # Windows NEEDS unicode but OpenElec utf-8
        try:
            exists = os.path.exists(filename)
        except:
            exists = os.path.exists(common.smart_utf8(filename))
        if exists:
            return filename, False
        else:
            tempdir = xbmc.translatePath("special://temp").decode("utf-8")
            basefilename = self.getname(filename)
            destination = os.path.join(tempdir, basefilename)
            xbmcvfs.copy(filename, destination)

            return common.smart_unicode(destination), True
コード例 #34
0
def convert_subtitles(closedcaption):
	str_output = ''
	count = 0
	for closedcaption_url, i in closedcaption:
		count = int(i) + 1
		if closedcaption_url is not None:
			try:
				cc_content = common.smart_unicode(connection.getURL(closedcaption_url, connectiontype = 0).replace(' 9137', ''))
				reader = detect_format(cc_content)
				if reader:
				
					str_output = common.smart_utf8(SRTWriter().write(reader().read(cc_content)))
					file = open(os.path.join(ustvpaths.DATAPATH, 'subtitle-%s.srt' % str(count)), 'w')
					file.write(str_output)
					str_output=''
					file.close()
				else:
					print "Unknown sub type"
			except  Exception, e:
				print "Exception with Subs: ", e
コード例 #35
0
 def onAction( self, action ):
     # Cancel
     if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CANCEL and action.getId() in SELECT_ITEM ):
         self.close()
     # Okay
     if ( self.getFocusId() == BUTTON_OK and action.getId() in SELECT_ITEM ):
         self.close()
     
     # Select or deselect item in list
     if ( action.getId() in SELECT_ITEM and self.getFocusId() == TAGS_LIST ):
         item = self.getControl( TAGS_LIST ).getSelectedItem()
         #pos  = self.getControl( TAGS_LIST ).getSelectedPosition()
         
         kb = xbmc.Keyboard(item.getLabel2(),  common.getstring(30623)%( common.smart_utf8(item.getLabel())), False)
         kb.doModal()
         if (kb.isConfirmed()):
             item.setLabel2(kb.getText())
             self.MPDB.set_tagtype_translation(common.smart_unicode(item.getLabel()), common.smart_unicode(item.getLabel2()))
             self.getControl( TAGS_LIST ).setVisible(False)
             self.getControl( TAGS_LIST ).setVisible(True)
コード例 #36
0
ファイル: pbs.py プロジェクト: Str8AWay/plugin.video.ustvvod
def masterlist():
	master_start = 0
	master_count = 200
	master_db = []
	master_dict = {}
	master_check = []
	#master_menu = simplejson.loads(connection.getURL(SHOWS, header = {'X-Requested-With' : 'XMLHttpRequest'}))
	#for master_item in master_menu.itervalues():
	#	for master_item in master_item:
#			master_check.append(master_item['title'])
	while master_start < master_count:
		master_data = cove.programs.filter(fields = 'mediafiles', order_by = 'title', limit_start = master_start, limit_end = 500)
		master_menu = master_data['results']
		master_count = master_data['count']
		master_stop = master_data['stop']
		print master_stop, master_count
		#del master_data
		for master_item2 in master_menu:
			website = master_item2['website']
			if website is None:
				website = ''
			if  ('PBS Kids' !=  master_item2['nola_root']) and ('blog' not in website):
				master_name = common.smart_utf8(master_item2['title'])
				print master_name
				season_url = re.compile('/cove/v1/programs/(.*?)/').findall(master_item2['resource_uri'])[0]
				tvdb_name = common.get_show_data(master_name, SITE, 'seasons', common.smart_unicode(master_name) + '#' +season_url)[-1]
				if season_url:
					if tvdb_name not in master_dict.keys():
						try:
							master_dict[tvdb_name] = common.smart_unicode(master_name) + '#' +season_url
						except Exception, e:
							print "e1", e
							return e
					else:
						try:
							master_dict[tvdb_name] = master_dict[tvdb_name] + '|' + common.smart_unicode(master_name) + '#' + season_url
						except Exception, e:
							print "error",e
							return e
				else:
					print "No season"
コード例 #37
0
def convert_subtitles(video_guid):
    try:
        file = None
        dialog = xbmcgui.DialogProgress()
        dialog.create(common.smart_utf8(addon.getLocalizedString(39026)))
        dialog.update(0, common.smart_utf8(addon.getLocalizedString(39027)))
        str_output = ""
        subtitle_data = connection.getURL(CLOSEDCAPTION % video_guid, connectiontype=0)
        subtitle_data = simplejson.loads(subtitle_data)
        lines_total = len(subtitle_data)
        dialog.update(0, common.smart_utf8(addon.getLocalizedString(39028)))
        for i, subtitle_line in enumerate(subtitle_data):
            if subtitle_line is not None and "Text" in subtitle_line["metadata"]:
                if dialog.iscanceled():
                    return
                if i % 10 == 0:
                    percent = int((float(i * 100) / lines_total))
                    dialog.update(percent, common.smart_utf8(addon.getLocalizedString(30929)))
                sub = common.smart_utf8(subtitle_line["metadata"]["Text"])
                start_time = common.smart_utf8(str(subtitle_line["startTime"])).split(".")
                start_minutes, start_seconds = divmod(int(start_time[0]), 60)
                start_hours, start_minutes = divmod(start_minutes, 60)
                start_time = "%02d:%02d:%02d,%02d" % (
                    start_hours,
                    start_minutes,
                    start_seconds,
                    int(start_time[1][0:2]),
                )
                end_time = common.smart_utf8(str(subtitle_line["endTime"])).split(".")
                end_minutes, end_seconds = divmod(int(end_time[0]), 60)
                end_hours, end_minutes = divmod(end_minutes, 60)
                end_time = "%02d:%02d:%02d,%02d" % (end_hours, end_minutes, end_seconds, int(end_time[1][0:2]))
                str_output += str(i + 1) + "\n" + start_time + " --> " + end_time + "\n" + sub + "\n\n"
        file = open(ustvpaths.SUBTITLE, "w")
        file.write(str_output)
        file.close()
    except Exception, e:
        print "Exception: " + unicode(e)
        common.show_exception(NAME, addon.getLocalizedString(39030))
コード例 #38
0
    def load_map(self):
        #google geolocalisation
        static_url = "http://maps.google.com/maps/api/staticmap?"
        param_dic = {  #location parameters (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html)
            "center": "",  #(required if markers not present)
            "zoom": self.zoomlevel,  # 0 to 21+ (req if no markers
            #map parameters
            "size": "640x640",  #widthxheight (required)
            "format":
            "jpg",  #"png8","png","png32","gif","jpg","jpg-baseline" (opt)
            "maptype":
            "hybrid",  #"roadmap","satellite","hybrid","terrain" (opt)
            "language": "",
            #Feature Parameters:
            "markers": "color:red|label:P|%s",  #(opt)
            #markers=color:red|label:P|lyon|12%20rue%20madiraa|marseille|Lille
            #&markers=color:blue|label:P|Australie
            "path": "",  #(opt)
            "visible": "",  #(opt)
            #Reporting Parameters:
            "sensor": "false"  #is there a gps on system ? (req)
        }

        param_dic["markers"] = param_dic["markers"] % self.place

        request_headers = {
            'User-Agent':
            'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10'
        }
        request = Request(static_url + urlencode(param_dic), None,
                          request_headers)
        try:
            urlfile = urlopen(request)
        except:
            dialog = xbmcgui.Dialog()
            dialog.ok('XBMC Network Error', 'Google maps is not reachable')
            self.close()
            return

        extension = urlfile.info().getheader("Content-Type", "").split("/")[1]
        filesize = int(urlfile.info().getheader("Content-Length", ""))

        mappath = xbmc.translatePath(self.datapath)
        mapfile = join(
            self.datapath,
            basename(self.filename).split(".")[0] +
            "_maps%s." % self.zoomlevel + extension)

        mapfile = xbmc.translatePath(mapfile)

        # test existence of path
        if not os.path.exists(mappath):
            os.makedirs(mappath)

        label = self.getControl(LABEL_TEXT)
        if not isfile(mapfile):
            #mapfile is not downloaded yet, download it now...
            try:
                #f=open(unicode(mapfile, 'utf-8'),"wb")
                f = open(common.smart_unicode(mapfile), "wb")
            except:
                try:
                    f = open(common.smart_utf8(mapfile), "wb")
                except:
                    print_exc()
                #print "GEO Exception: "+mapfile
            for i in range(1 + (filesize / 10)):
                f.write(urlfile.read(10))
                label.setLabel(
                    common.getstring(30221) %
                    (100 *
                     (float(i * 10) / filesize)))  #getting map... (%0.2f%%)
            urlfile.close()
            #pDialog.close()
            try:
                f.close()
            except:
                print_exc()
        self.set_pic(self.filename)
        self.set_map(mapfile)
        label.setLabel(
            common.getstring(30222) %
            int(100 * (float(self.zoomlevel) / self.zoom_max)))  #Zoom level %s
コード例 #39
0
	def SaveFile(self, filename, data, dir):
		path = os.path.join(dir, filename)
		file = open(path, 'w')
		data = common.smart_utf8(data)
		file.write(data)
		file.close()
コード例 #40
0
ファイル: addon.py プロジェクト: MarkTV/MarkTV
def modes():
	if sys.argv[2] == '':
		all_description = ''
		networks = common.get_networks()
		networks.sort(key = lambda x: x.SITE.replace('the', ''))
		for network in networks:
			if addon.getSetting(network.SITE) == 'true':
				if network.NAME.endswith(', The'):
					name = 'The ' + network.NAME.replace(', The', '')
				all_description += network.NAME + ', '
		count = 0
		cmlib = [ (common.smart_utf8(addon.getLocalizedString(39034)) % common.smart_utf8(addon.getLocalizedString(39000)), "XBMC.RunPlugin(%s?mode='ForceFavoriteEpisodesLibrary')" % ( sys.argv[0] ) ) ]
		cmlib.append( (common.smart_utf8(addon.getLocalizedString(39035)), "XBMC.RunPlugin(%s?mode='ClearLibrary')" % ( sys.argv[0] ) ) )
		common.add_directory(common.smart_utf8(addon.getLocalizedString(39000)), 'Favorlist', 'NoUrl', thumb = ustvpaths.FAVICON, count = count, description = common.smart_utf8(addon.getLocalizedString(39001)) + '\n' + all_description,  contextmenu = cmlib)
		count += 1
		cmlib = [ (common.smart_utf8(addon.getLocalizedString(39034)) % common.smart_utf8(addon.getLocalizedString(39002)), "XBMC.RunPlugin(%s?mode='AllShowsLibrary')" % ( sys.argv[0] ) ) ]
		cmlib.append( (common.smart_utf8(addon.getLocalizedString(39035)), "XBMC.RunPlugin(%s?mode='ClearLibrary')" % ( sys.argv[0] ) ) )
		common.add_directory(common.smart_utf8(addon.getLocalizedString(39002)), 'Masterlist', 'NoUrl', thumb = ustvpaths.ALLICON, count = count, description = common.smart_utf8(addon.getLocalizedString(39003)) + '\n' + all_description,  contextmenu = cmlib)
		count += 1
		for network in networks:
			network_name = network.NAME
			station_icon = os.path.join(ustvpaths.IMAGEPATH, network.SITE + '.png')
			if network_name.endswith(', The'):
				network_name = 'The ' + network_name.replace(', The', '')
			if addon.getSetting(network.SITE) == 'true':
				cmlib = [ (common.smart_utf8(addon.getLocalizedString(39034)) % network_name, "XBMC.RunPlugin(%s?mode='NetworkLibrary&submode='%s')" % ( sys.argv[0], network.SITE ) ) ]
				cmlib.append( (common.smart_utf8(addon.getLocalizedString(39035)), "XBMC.RunPlugin(%s?mode='ClearLibrary')" % ( sys.argv[0] ) ) )
				common.add_directory(network_name, network.SITE, 'rootlist', thumb = station_icon, fanart = ustvpaths.PLUGINFANART, description = network.DESCRIPTION, count = count, contextmenu = cmlib)
			count += 1
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_PLAYLIST_ORDER)
		common.set_view()
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode.endswith('Library'):
		xbmclibrary.Main()
	elif common.args.mode == 'Masterlist':
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.load_showlist()
		common.set_view('tvshows')
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.sitemode == 'rootlist':
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.root_list(common.args.mode)
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.sitemode.startswith('seasons'):
		common.season_list()
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.sitemode.startswith('episodes'):
		try:
			common.episode_list()
		except Exception as e:
			print "Error in Episodes:" + e
		if addon.getSetting('add_episode_identifier') == 'false':
			try:
				xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_DATEADDED)
			except:
				pass
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_EPISODE)
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_UNSORTED)
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_MPAA_RATING)
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_GENRE)
			xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_VIDEO_RATING)
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode == 'Favorlist':   
		xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
		common.load_showlist(favored = 1)
		common.set_view('tvshows')
		xbmcplugin.endOfDirectory(pluginHandle)
	elif common.args.mode == 'contextmenu':
		getattr(contextmenu, common.args.sitemode)()
	elif common.args.mode == 'common':
		getattr(common, common.args.sitemode)()
	else:
		network = common.get_network(common.args.mode)
		if network:
			getattr(network, common.args.sitemode)()
			if 'episodes' in  common.args.sitemode and addon.getSetting('add_episode_identifier') == 'false':
				try:
					xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_DATEADDED)
				except:
					pass
				xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_EPISODE)
				xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_UNSORTED)
			if not common.args.sitemode.startswith('play'):
				xbmcplugin.endOfDirectory(pluginHandle)
コード例 #41
0
def modes():
    if sys.argv[2] == '':
        all_description = ''
        networks = common.get_networks()
        networks.sort(key=lambda x: x.SITE.replace('the', ''))
        for network in networks:
            if addon.getSetting(network.SITE) == 'true':
                if network.NAME.endswith(', The'):
                    name = 'The ' + network.NAME.replace(', The', '')
                all_description += network.NAME + ', '
        count = 0
        cmlib = [(common.smart_utf8(addon.getLocalizedString(39034)) %
                  common.smart_utf8(addon.getLocalizedString(39000)),
                  "XBMC.RunPlugin(%s?mode='ForceFavoriteEpisodesLibrary')" %
                  (sys.argv[0]))]
        cmlib.append(
            (common.smart_utf8(addon.getLocalizedString(39035)),
             "XBMC.RunPlugin(%s?mode='ClearLibrary')" % (sys.argv[0])))
        export_u = sys.argv[0] + '?url="<join>"' + sys.argv[
            0] + '?url="' + '&mode=contextmenu' + '&sitemode=export_fav'

        cmlib.append(('Export Favorites', 'XBMC.RunPlugin(%s)' % export_u))
        del_u = sys.argv[0] + '?url="<join>"' + sys.argv[
            0] + '?url="' + '&mode=contextmenu' + '&sitemode=del_fav'

        cmlib.append(('Delete Favorites', 'XBMC.RunPlugin(%s)' % del_u))
        import_u = sys.argv[0] + '?url="<join>"' + sys.argv[
            0] + '?url="' + '&mode=contextmenu' + '&sitemode=import_fav'

        cmlib.append(('Import Favorites', 'XBMC.RunPlugin(%s)' % import_u))
        common.add_directory(
            common.smart_utf8(addon.getLocalizedString(39000)),
            'Favorlist',
            'NoUrl',
            thumb=ustvpaths.FAVICON,
            count=count,
            description=common.smart_utf8(addon.getLocalizedString(39001)) +
            '\n' + all_description,
            contextmenu=cmlib)
        count += 1
        cmlib = [(common.smart_utf8(addon.getLocalizedString(39034)) %
                  common.smart_utf8(addon.getLocalizedString(39002)),
                  "XBMC.RunPlugin(%s?mode='AllShowsLibrary')" % (sys.argv[0]))]
        cmlib.append(
            (common.smart_utf8(addon.getLocalizedString(39035)),
             "XBMC.RunPlugin(%s?mode='ClearLibrary')" % (sys.argv[0])))
        common.add_directory(
            common.smart_utf8(addon.getLocalizedString(39002)),
            'Masterlist',
            'NoUrl',
            thumb=ustvpaths.ALLICON,
            count=count,
            description=common.smart_utf8(addon.getLocalizedString(39003)) +
            '\n' + all_description,
            contextmenu=cmlib)
        count += 1
        for network in networks:
            network_name = network.NAME
            station_icon = os.path.join(ustvpaths.IMAGEPATH,
                                        network.SITE + '.png')
            if network_name.endswith(', The'):
                network_name = 'The ' + network_name.replace(', The', '')
            if addon.getSetting(network.SITE) == 'true':
                cmlib = [
                    (common.smart_utf8(addon.getLocalizedString(39034)) %
                     network_name,
                     "XBMC.RunPlugin(%s?mode='NetworkLibrary&submode='%s')" %
                     (sys.argv[0], network.SITE))
                ]
                cmlib.append(
                    (common.smart_utf8(addon.getLocalizedString(39035)),
                     "XBMC.RunPlugin(%s?mode='ClearLibrary')" % (sys.argv[0])))
                common.add_directory(network_name,
                                     network.SITE,
                                     'rootlist',
                                     thumb=station_icon,
                                     fanart=ustvpaths.PLUGINFANART,
                                     description=network.DESCRIPTION,
                                     count=count,
                                     contextmenu=cmlib)
            count += 1
        xbmcplugin.addSortMethod(pluginHandle,
                                 xbmcplugin.SORT_METHOD_PLAYLIST_ORDER)
        common.set_view()
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.mode.startswith('script_check'):
        try:
            updater = xbmcaddon.Addon('script.ustvvodlibraryautoupdate')
            updater.openSettings()
        except:
            dialog = xbmcgui.Dialog()
            dialog.ok(addon.getAddonInfo('name'),
                      addon.getLocalizedString(39041))
    elif common.args.mode.startswith('script_sources'):
        xbmclibrary.Validate()
    elif common.args.mode.endswith('Library'):
        xbmclibrary.Main()
    elif common.args.mode == 'Masterlist':
        xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
        common.load_showlist()
        common.set_view('tvshows')
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.sitemode == 'rootlist':
        xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
        common.root_list(common.args.mode)
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.sitemode.startswith('seasons'):
        common.season_list()
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.sitemode.startswith('episodes'):
        try:
            common.episode_list()
        except Exception as e:
            print "Error in Episodes:" + e
        if addon.getSetting('add_episode_identifier') == 'false':
            try:
                xbmcplugin.addSortMethod(pluginHandle,
                                         xbmcplugin.SORT_METHOD_DATEADDED)
            except:
                pass
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_EPISODE)
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_UNSORTED)
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_LABEL)
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_MPAA_RATING)
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_GENRE)
            xbmcplugin.addSortMethod(pluginHandle,
                                     xbmcplugin.SORT_METHOD_VIDEO_RATING)
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.mode == 'Favorlist':
        xbmcplugin.addSortMethod(pluginHandle, xbmcplugin.SORT_METHOD_LABEL)
        common.load_showlist(favored=1)
        common.set_view('tvshows')
        xbmcplugin.endOfDirectory(pluginHandle)
    elif common.args.mode == 'contextmenu':
        getattr(contextmenu, common.args.sitemode)()
    elif common.args.mode == 'common':
        getattr(common, common.args.sitemode)()
    else:
        network = common.get_network(common.args.mode)
        if network:
            getattr(network, common.args.sitemode)()
            if 'episodes' in common.args.sitemode and addon.getSetting(
                    'add_episode_identifier') == 'false':
                try:
                    xbmcplugin.addSortMethod(pluginHandle,
                                             xbmcplugin.SORT_METHOD_DATEADDED)
                except:
                    pass
                xbmcplugin.addSortMethod(pluginHandle,
                                         xbmcplugin.SORT_METHOD_EPISODE)
                xbmcplugin.addSortMethod(pluginHandle,
                                         xbmcplugin.SORT_METHOD_UNSORTED)
            if not common.args.sitemode.startswith('play'):
                xbmcplugin.endOfDirectory(pluginHandle)
コード例 #42
0
 def SaveFile(self, filename, data, dir):
     path = os.path.join(dir, filename)
     file = open(path, 'w')
     data = common.smart_utf8(data)
     file.write(data)
     file.close()
コード例 #43
0
    def load_map(self):
        #google geolocalisation
        static_url = "http://maps.google.com/maps/api/staticmap?"
        param_dic = {#location parameters (http://gmaps-samples.googlecode.com/svn/trunk/geocoder/singlegeocode.html)
                     "center":"",       #(required if markers not present)
                     "zoom":self.zoomlevel,         # 0 to 21+ (req if no markers
                     #map parameters
                     "size":"640x640",  #widthxheight (required)
                     "format":"jpg",    #"png8","png","png32","gif","jpg","jpg-baseline" (opt)
                     "maptype":"hybrid",      #"roadmap","satellite","hybrid","terrain" (opt)
                     "language":"",
                     #Feature Parameters:
                     "markers" :"color:red|label:P|%s",#(opt)
                                        #markers=color:red|label:P|lyon|12%20rue%20madiraa|marseille|Lille
                                        #&markers=color:blue|label:P|Australie
                     "path" : "",       #(opt)
                     "visible" : "",    #(opt)
                     #Reporting Parameters:
                     "sensor" : "false" #is there a gps on system ? (req)
                     }

        param_dic["markers"]=param_dic["markers"]%self.place

        request_headers = { 'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; fr; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10' }
        request = Request(static_url+urlencode(param_dic), None, request_headers)
        try:
            urlfile = urlopen(request)
        except:
            dialog = xbmcgui.Dialog()
            dialog.ok('XBMC Network Error', 'Google maps is not reachable')
            self.close()
            return
            
        extension = urlfile.info().getheader("Content-Type","").split("/")[1]
        filesize = int(urlfile.info().getheader("Content-Length",""))

        mappath = xbmc.translatePath(self.datapath)
        mapfile = join(self.datapath,basename(self.filename).split(".")[0]+"_maps%s."%self.zoomlevel+extension)

        mapfile = xbmc.translatePath(mapfile)

        # test existence of path
        if not os.path.exists(mappath):
            os.makedirs(mappath)
        
        label = self.getControl( LABEL_TEXT )
        if not isfile(mapfile):
            #mapfile is not downloaded yet, download it now...
            try:
                #f=open(unicode(mapfile, 'utf-8'),"wb")
                f=open(common.smart_unicode(mapfile), "wb")
            except:
                try:
                    f=open(common.smart_utf8(mapfile), "wb")
                except:
                    print_exc()
                #print "GEO Exception: "+mapfile
            for i in range(1+(filesize/10)):
                f.write(urlfile.read(10))
                label.setLabel(common.getstring(30221)%(100*(float(i*10)/filesize)))#getting map... (%0.2f%%)
            urlfile.close()
            #pDialog.close()
            try:
                f.close()
            except:
                print_exc()
        self.set_pic(self.filename)
        self.set_map(mapfile)
        label.setLabel(common.getstring(30222)%int(100*(float(self.zoomlevel)/self.zoom_max)))#Zoom level %s