コード例 #1
0
ファイル: api.py プロジェクト: wolfhowlmedia/livestream
	def __init__(self, channel, method = 'json'):
		self.set_channel(channel)
		self.set_retrieval_mode(method)
		if method == 'json':
			from api_json import Parser_JSON as Parser

		self.parser = Parser(self.apiuri % channel.replace('_', '-'))
コード例 #2
0
ファイル: api.py プロジェクト: wolfhowlmedia/livestream
class LSAPI :
	channel = ''
	method = 'json'
	apiuri = 'http://x%sx.api.channel.livestream.com/2.0/'


	#init
	def __init__(self, channel, method = 'json'):
		self.set_channel(channel)
		self.set_retrieval_mode(method)
		if method == 'json':
			from api_json import Parser_JSON as Parser

		self.parser = Parser(self.apiuri % channel.replace('_', '-'))

	"""
	Setting up API
	"""
	def set_retrieval_mode(self, method):
		self.method = method
		self._test_retrieval_method()


	def set_channel(self, channel):
		if channel.strip() == '':
			raise LSChannelException('Channel cannot be empty!')

		self.channel = channel

	"""
	Getting information back
	"""
	#get channel name
	def get_channel_name(self):
		return self.channel

	#get retrieval method
	def get_retrieval_mode(self):
		return self.method

	"""
	Get API information
	"""
	#get list of channel folders
	def get_channel_playlist(self):
		pass
	
	#Is channel online?
	def get_channel_live_status(self):
		return self.parser.get_channel_live_status()
	
	#get clips from folder
	def get_channel_clips(self, directory_id):
		pass

	#get latest chanel clips
	def get_channel_latest_clips(self):
		pass
	
	#get detailed clip info
	def get_clip_info(self, clip_id):
		pass
	
	#get detailed channel info
	def get_channel_info(self):
		return self.parser.get_channel_info()

	#get events info
	def get_channel_events(self):
		pass


	#internal checking. don't touch.
	def _test_retrieval_method(self):
		if self.method != 'json' and self.method != 'xml':
			raise LSMethodException('Retrival method sould be either json or xml.')