def isConfirmCommitted(curl): try: page = HTTP.Request( common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN) + '&confirm=' + common_fnc.encode(curl)).content if 'Confirmed Commit' in page: return True except: pass return False
def commit(curl, data): try: #Log("----------------------------------------------------- ") #dateToday = DT.datetime.utcnow() #commit_time = str(dateToday.month) + '/' + str(dateToday.day) + '/' + str(dateToday.year) #commit_time = str(dateToday + ' UTC') #Log("commit_time --------- " + commit_time) #Log("data ------------- " + data) attempt = 0 while (attempt < 2): page = HTTP.Request( common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN)).content elems = HTML.ElementFromString(page) try: auth = elems.xpath(".//div[@class='validate']//@value")[0] except: auth = None if 'Ready for cCloud TV Commit' in page and auth <> None and len( auth) == 32: content = common_fnc.encode(data) #Log("content = " + content) # make commit try: resp = HTTP.Request( common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN) + '&data=' + content + '&validate=' + auth).content if 'Success: Data Comitted to cCloud TV' in resp: ARRAY_COMITTED_URLS.append(curl) return True except: pass #print(e.reason) else: return False attempt = attempt + 1 except: return False return False
def commit(curl, data): try: #Log("----------------------------------------------------- ") #dateToday = DT.datetime.utcnow() #commit_time = str(dateToday.month) + '/' + str(dateToday.day) + '/' + str(dateToday.year) #commit_time = str(dateToday + ' UTC') #Log("commit_time --------- " + commit_time) #Log("data ------------- " + data) attempt = 0 while (attempt < 2): page = HTTP.Request(common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN)).content elems = HTML.ElementFromString(page) try: auth = elems.xpath(".//div[@class='validate']//@value")[0] except: auth = None if 'Ready for cCloud TV Commit' in page and auth <> None: content = common_fnc.encode(data) #Log("content = " + content) # make commit try: resp = HTTP.Request(common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN) + '&data=' + content + '&validate=' + auth).content if 'Success: Data Comitted to cCloud TV' in resp: ARRAY_COMITTED_URLS.append(curl) return True except: pass #print(e.reason) else: return False attempt = attempt + 1 except: return False return False
def CreateVideoClipObject(url, title, thumb, summary, session, inc_container=False, transcode=False): vco = '' if '.mp3' in url or '.aac' in url or 'mmsh:' in url: container = Container.MP4 audio_codec = AudioCodec.AAC if '.mp3' in url: container = 'mp3' audio_codec = AudioCodec.MP3 elif '.aac' in url: container = 'aac' audio_codec = AudioCodec.AAC vco = TrackObject(key=Callback(CreateVideoClipObject, url=url, title=title, thumb=thumb, summary=summary, session=session, inc_container=True), rating_key=url, title=title, thumb=thumb, summary=summary, items=[ MediaObject(parts=[PartObject(key=url)], container=container, audio_codec=audio_codec, audio_channels=2) ]) elif '.mp4' in url and '.m3u8' not in url: # we will base64 encode the url, so that any conflicting url service does not interfere vco = VideoClipObject(url=common_fnc.encode(url) + 'cCloudVid' + title + 'cCloudVid' + summary + 'cCloudVid' + thumb, title=title, thumb=thumb, summary=summary) elif common_fnc.ArrayItemsInString(MP4_VIDEOS, url) and '.m3u8' not in url: # we will base64 encode the url, so that any conflicting url service does not interfere vco = VideoClipObject(url=common_fnc.encode(url) + 'cCloudVid' + title + 'cCloudVid' + summary + 'cCloudVid' + thumb, title=title, thumb=thumb, summary=summary) elif '.m3u8' not in url and 'rtmp:' in url and transcode: # transcode case #if inc_container: file = "file:///" + res_folder_path.replace('\\', '/').replace( ' ', '%20') + "MyPreRoll.mp4" live_folder_path = Prefs['transcode_server_local'] bool = transcoder.Transcoder(url, live_folder_path, session, '.m3u8', file, False, True, False) if bool: if 'Host' in Request.Headers: host = Request.Headers['Host'] host = host.replace('-', '.') else: host = None if Prefs['debug']: Log("Host ---------------- " + str(host)) url = Prefs['transcode_server'] + session + '.m3u8' vco = VideoClipObject( key=Callback(CreateVideoClipObject, url=url, title=title, thumb=thumb, summary=summary, session=session, inc_container=True, transcode=transcode), #rating_key = url, url=url, title=title, summary=summary, thumb=thumb, items=[ MediaObject( #container = Container.MP4, # MP4, MKV, MOV, AVI #video_codec = VideoCodec.H264, # H264 #audio_codec = AudioCodec.AAC, # ACC, MP3 #audio_channels = 2, # 2, 6 #container = container, #audio_codec = audio_codec, parts=[ PartObject(key=GetVideoURL(url=url, live=True, transcode=transcode, finalPlay=inc_container)) ], optimized_for_streaming=True) ]) else: vco = VideoClipObject( key=Callback(CreateVideoClipObject, url=url, title=title, thumb=thumb, summary=summary, session=session, inc_container=True), #rating_key = url, url=url, title=title, summary=summary, thumb=thumb, items=[ MediaObject( #container = Container.MP4, # MP4, MKV, MOV, AVI #video_codec = VideoCodec.H264, # H264 #audio_codec = AudioCodec.AAC, # ACC, MP3 #audio_channels = 2, # 2, 6 #container = container, #audio_codec = audio_codec, parts=[ PartObject(key=GetVideoURL(url=url, live=True, transcode=transcode, finalPlay=inc_container)) ], optimized_for_streaming=True) ]) if inc_container: return ObjectContainer(objects=[vco]) else: return vco
def CreateVideoClipObject(url, title, thumb, summary, session, inc_container = False, transcode = False): vco = '' if '.mp3' in url or '.aac' in url or 'mmsh:' in url: container = Container.MP4 audio_codec = AudioCodec.AAC if '.mp3' in url: container = 'mp3' audio_codec = AudioCodec.MP3 elif '.aac' in url: container = 'aac' audio_codec = AudioCodec.AAC vco = TrackObject( key = Callback(CreateVideoClipObject, url = url, title = title, thumb = thumb, summary = summary, session = session, inc_container = True), rating_key = url, title = title, thumb = thumb, summary = summary, items = [ MediaObject( parts = [ PartObject(key=url) ], container = container, audio_codec = audio_codec, audio_channels = 2 ) ] ) elif '.mp4' in url and '.m3u8' not in url: # we will base64 encode the url, so that any conflicting url service does not interfere vco = VideoClipObject( url = common_fnc.encode(url) + 'cCloudVid' + title + 'cCloudVid' + summary + 'cCloudVid' + thumb, title = title, thumb = thumb, summary = summary ) elif common_fnc.ArrayItemsInString(MP4_VIDEOS, url) and '.m3u8' not in url: # we will base64 encode the url, so that any conflicting url service does not interfere vco = VideoClipObject( url = common_fnc.encode(url) + 'cCloudVid' + title + 'cCloudVid' + summary + 'cCloudVid' + thumb, title = title, thumb = thumb, summary = summary ) elif '.m3u8' not in url and 'rtmp:' in url and transcode: # transcode case #if inc_container: file = "file:///" + res_folder_path.replace('\\','/').replace(' ','%20') + "MyPreRoll.mp4" live_folder_path = Prefs['transcode_server_local'] bool = transcoder.Transcoder(url, live_folder_path, session , '.m3u8', file, False, True, False) if bool: if 'Host' in Request.Headers: host = Request.Headers['Host'] host = host.replace('-','.') else: host = None if Prefs['debug']: Log("Host ---------------- " + str(host)) url = Prefs['transcode_server'] + session + '.m3u8' vco = VideoClipObject( key = Callback(CreateVideoClipObject, url = url, title = title, thumb = thumb, summary = summary, session = session, inc_container = True, transcode=transcode), #rating_key = url, url = url, title = title, summary = summary, thumb = thumb, items = [ MediaObject( #container = Container.MP4, # MP4, MKV, MOV, AVI #video_codec = VideoCodec.H264, # H264 #audio_codec = AudioCodec.AAC, # ACC, MP3 #audio_channels = 2, # 2, 6 #container = container, #audio_codec = audio_codec, parts = [ PartObject( key = GetVideoURL(url = url, live = True, transcode=transcode, finalPlay=inc_container) ) ], optimized_for_streaming = True ) ] ) else: vco = VideoClipObject( key = Callback(CreateVideoClipObject, url = url, title = title, thumb = thumb, summary = summary, session = session, inc_container = True), #rating_key = url, url = url, title = title, summary = summary, thumb = thumb, items = [ MediaObject( #container = Container.MP4, # MP4, MKV, MOV, AVI #video_codec = VideoCodec.H264, # H264 #audio_codec = AudioCodec.AAC, # ACC, MP3 #audio_channels = 2, # 2, 6 #container = container, #audio_codec = audio_codec, parts = [ PartObject( key = GetVideoURL(url = url, live = True, transcode=transcode, finalPlay=inc_container) ) ], optimized_for_streaming = True ) ] ) if inc_container: return ObjectContainer(objects = [vco]) else: return vco
def isConfirmCommitted(curl): try: page = HTTP.Request(common_fnc.decode(COMMIT_URL) + '?token=' + common_fnc.decode(MY_TOKEN) + '&confirm=' + common_fnc.encode(curl)).content if 'Confirmed Commit' in page: return True except: pass return False