Esempio n. 1
0
 def _lotterVideo(self):
     from resources.lib.extensions import interface
     path = tools.File.joinPath(tools.System.pathResources(), 'resources',
                                'media', 'video', 'lottery', 'Gaia.m3u')
     player = interface.Player()
     if not player.isPlaying():
         player.play(path)
Esempio n. 2
0
	def lotteryDialog(self):
		from resources.lib.extensions import interface
		type = tools.Settings.getString('general.statistics.lottery.type')
		voucher = tools.Settings.getString('general.statistics.lottery.voucher')
		description = tools.Settings.getString('general.statistics.lottery.description')
		instruction = tools.Settings.getString('general.statistics.lottery.instruction')
		timeClaim = tools.Settings.getInteger('general.statistics.lottery.time.claim')
		timeExpiry = tools.Settings.getInteger('general.statistics.lottery.time.expiry')
		timeDuration = tools.Settings.getInteger('general.statistics.lottery.time.duration')
		indent = '     '
		message = interface.Format.bold(interface.Translation.string(33875)) + interface.Format.newline()
		message += '%s%s: %s' % (indent, interface.Translation.string(33343), interface.Format.bold(type)) + interface.Format.newline()
		message += '%s%s: %s' % (indent, interface.Translation.string(33876), interface.Format.bold(voucher)) + interface.Format.newline()
		if description:
			message += '%s%s: %s' % (indent, interface.Translation.string(33040), interface.Format.bold(description)) + interface.Format.newline()
		if instruction:
			message += instruction
			if not message.endswith('.'): message += '.'
		if timeExpiry and timeDuration:
			expirationDuration = convert.ConverterDuration(timeDuration, convert.ConverterDuration.UnitSecond).string(format = convert.ConverterDuration.FormatWordLong, unit = convert.ConverterDuration.UnitDay)
			expirationTime = convert.ConverterTime(timeExpiry, convert.ConverterTime.FormatTimestamp).string(format = convert.ConverterTime.FormatDate)
			expiration = '%s (%s)' % (expirationDuration, expirationTime)
			message += ' ' + (interface.Translation.string(33877) % expiration)
		message += ' ' + interface.Translation.string(33878)

		interface.Dialog.confirm(title = 33879, message = message)
		interface.Player().stop()
Esempio n. 3
0
	def handle(self, link, item, download = False, popups = False, close = True, select = False, cloud = False):
		try:
			parameters = {}

			# Link
			parameters['uri'] = network.Networker.quote(link)

			# Type
			type = None
			if 'type' in item and not 'type' == None:
				if item['type'] == tools.Media.TypeShow:
					type = 'episode'
				else:
					type = 'movie'
			elif 'tvshowtitle' in item:
				type = 'episode'
			else:
				type = 'movie'
			parameters['type'] = type

			# Information
			information = item['information'] if 'information' in item else None

			# Show
			if type == 'episode':
				if 'season' in information:
					parameters['season'] = information['season']
				if 'episode' in information:
					parameters['episode'] = information['episode']

			# TMDB
			try:
				tmdbApi = tools.Settings.getString('accounts.informants.tmdb.api') if tools.Settings.getBoolean('accounts.informants.tmdb.enabled') else ''
				if tmdbApi == '': tmdbApi = tools.System.obfuscate(tools.Settings.getString('internal.tmdb.api', raw = True))
				if not tmdbApi == '':
					if 'tvdb' in information and not information['tvdb'] == None: # Shows - IMDB ID for episodes does not work on tmdb
						result = cache.get(client.request, 240, 'http://api.themoviedb.org/3/find/%s?api_key=%s&external_source=tvdb_id' % (information['tvdb'], tmdbApi))
						result = result['tv_episode_results']
						parameters['tmdb'] = str(result['id'])
						parameters['show'] = str(result['show_id'])
					elif 'imdb' in information and not information['imdb'] == None:
						result = cache.get(client.request, 240, 'http://api.themoviedb.org/3/find/%s?api_key=%s&external_source=imdb_id' % (information['imdb'], tmdbApi))
						if isinstance(result, basestring): result = tools.Converter.jsonFrom(result)
						result = result['movie_results']
						if isinstance(result, list): result = result[0]
						parameters['tmdb'] = str(result['id'])
			except:
				tools.Logger.error()

			# This will add the torrent to Quasar, but after Quasar's buffer phase, playback is not started and nothing happens.
			# This is because of the source-selection dialog that causes Kodi's addon handle to be -1 (aka no handle). This will cause the Kodi player to not launch.
			# Use the RPC instead.
			# action = 'torrents/add' if download else 'play'
			#parameters = network.Networker.linkParameters(parameters)
			#tools.System.execute('RunPlugin(plugin://plugin.video.quasar/%s?%s)' % (action, parameters))

			interface.Dialog.notification(title = 33570, message = 35320, icon = interface.Dialog.IconSuccess, time = 10000)
			interface.Core.close()
			interface.Loader.show()

			if download: network.Networker(tools.Quasar.linkAdd(parameters)).request()
			else: network.Networker(tools.Quasar.linkPlay(parameters)).request()

			tools.Time.sleep(1)
			while True:
				if interface.Dialog.dialogProgressVisible(): break
				tools.Time.sleep(0.5)

			interface.Loader.hide()

			while True:
				if not interface.Dialog.dialogProgressVisible(): break
				tools.Time.sleep(0.5)

			# Quasar does not start playback after initial buffering.
			# If requesting the link again after buffering is done, Quasar does start playback.
			if not download:
				if not interface.Player().isPlaying(): interface.Loader.show()
				tools.Time.sleep(3)
				if not interface.Player().isPlaying(): network.Networker(tools.Quasar.linkPlay({'resume' : parameters['uri']})).request()
				interface.Loader.hide()

			if interface.Player().isPlaying() and window.WindowStreams.enabled():
				window.WindowStreams.close()

			return debrid.Debrid.addResult(error = Handler.ReturnExternal) # Return because Quasar will handle the playback.
		except:
			tools.Logger.error()