def GetVideoObject(name, channel_id, thumb, files, container): video = MovieObject(rating_key='rating_key', title=unicode(name), thumb=Resource.ContentsOfURLWithFallback(url=thumb)) offset = video_service.get_offset(common.get_time_shift()) format = 'mp4' new_files = json.loads(urllib.unquote_plus(files)) bitrates = video_service.bitrates(new_files, accepted_format=format, quality_level=common.get_quality_level()) video.key = Callback(GetLiveChannel, name=name, channel_id=channel_id, thumb=thumb, files=files, container=True) video.items = MediaObjectsForURL(channel_id=channel_id, format=format, offset=offset, bitrates=json.dumps(bitrates[format])) return video
def add_schedule(oc, channel_id, default_time, list): channels = video_service.get_live_channels()['data'] channel = find_channel(int(channel_id), channels) offset = video_service.get_offset(common.get_time_shift()) time_delta = datetime.timedelta(hours=offset) files = channel['files'] for media in list: start_time = get_time(media['start_time']) finish_time = get_time(media['finish_time']) current_title = in_time_range(default_time - time_delta, start_time, finish_time) if media['media_id']: if media['rating']: rating = media['rating'] else: rating = 'unknown' key = Callback(archive.HandleChild, id=media['media_id'], name=media['name'], thumb='thumb', rating_key=rating, description=media['description'], duration=0, year=0, on_air=media['start_time'], index=0, files=json.dumps(files)) title = get_schedule_title(media['name'], start_time, finish_time, current_title=current_title) oc.add(DirectoryObject(key=key, title=unicode(title))) else: select_key = Callback(GetSchedule, channel_id=channel_id) title = get_schedule_title(media['name'], start_time, finish_time, current_title=current_title, available=False) oc.add(DirectoryObject(key=select_key, title=unicode(title)))
def add_schedule(oc, channel_id, default_time, list): channels = video_service.get_live_channels()["data"] channel = find_channel(int(channel_id), channels) offset = video_service.get_offset(common.get_time_shift()) time_delta = datetime.timedelta(hours=offset) files = channel["files"] for media in list: start_time = get_time(media["start_time"]) finish_time = get_time(media["finish_time"]) current_title = in_time_range(default_time - time_delta, start_time, finish_time) if media["media_id"]: if media["rating"]: rating = media["rating"] else: rating = "unknown" key = Callback( archive.HandleChild, id=media["media_id"], name=media["name"], thumb="thumb", rating_key=rating, description=media["description"], duration=0, year=0, on_air=media["start_time"], index=0, files=json.dumps(files), ) title = get_schedule_title(media["name"], start_time, finish_time, current_title=current_title) oc.add(DirectoryObject(key=key, title=unicode(title))) else: select_key = Callback(GetSchedule, channel_id=channel_id) title = get_schedule_title( media["name"], start_time, finish_time, current_title=current_title, available=False ) oc.add(DirectoryObject(key=select_key, title=unicode(title)))
def GetVideoObject(name, channel_id, thumb, files, container): video = MovieObject( rating_key="rating_key", title=unicode(name), thumb=Resource.ContentsOfURLWithFallback(url=thumb) ) offset = video_service.get_offset(common.get_time_shift()) format = "mp4" new_files = json.loads(urllib.unquote_plus(files)) bitrates = video_service.bitrates(new_files, accepted_format=format, quality_level=common.get_quality_level()) video.key = Callback(GetLiveChannel, name=name, channel_id=channel_id, thumb=thumb, files=files, container=True) video.items = MediaObjectsForURL( channel_id=channel_id, format=format, offset=offset, bitrates=json.dumps(bitrates[format]) ) return video