def hello_world(): create_asset_request = mux_python.CreateAssetRequest( playback_policy=[mux_python.PlaybackPolicy.PUBLIC]) create_upload_request = mux_python.CreateUploadRequest( timeout=3600, new_asset_settings=create_asset_request, cors_origin="*") create_upload_response = uploads_api.create_direct_upload( create_upload_request) print(create_upload_response) d = { "url": create_upload_response.data.url, "id": create_upload_response.data.id } return json.dumps(d)
def _create_mux_asset(self, s3_url): try: assets_api = self._create_mux_client() input_settings = [mux_python.InputSettings(url=s3_url)] create_asset_request = mux_python.CreateAssetRequest( input=input_settings) create_asset_response = assets_api.create_asset( create_asset_request) print("RESONSE : ") print(create_asset_response) return create_asset_response.data.id except Exception as e: print("ERROR:", e) return None
from mux_python.rest import NotFoundException import logger # Exercises all live stream operations. # Authentication Setup configuration = mux_python.Configuration() configuration.username = os.environ['MUX_TOKEN_ID'] configuration.password = os.environ['MUX_TOKEN_SECRET'] # API Client Initialization live_api = mux_python.LiveStreamsApi(mux_python.ApiClient(configuration)) playback_ids_api = mux_python.PlaybackIDApi(mux_python.ApiClient(configuration)) # ========== create-live-stream ========== new_asset_settings = mux_python.CreateAssetRequest(playback_policy=[mux_python.PlaybackPolicy.PUBLIC]) create_live_stream_request = mux_python.CreateLiveStreamRequest(playback_policy=[mux_python.PlaybackPolicy.PUBLIC], new_asset_settings=new_asset_settings) create_live_stream_response = live_api.create_live_stream(create_live_stream_request) logger.print_debug(str(create_live_stream_response)) assert create_live_stream_response != None assert create_live_stream_response.data != None assert create_live_stream_response.data.id != None print("create-live-stream OK ✅") # ========== list-live-streams ========== list_live_streams_response = live_api.list_live_streams() logger.print_debug(str(list_live_streams_response)) assert list_live_streams_response != None assert list_live_streams_response.data != None assert list_live_streams_response.data[0].id == create_live_stream_response.data.id print("list-live-streams OK ✅")
def create_asset(self): # Create an asset self.input_settings = [mux_python.InputSettings(url=self.video)] self.create_asset_request = mux_python.CreateAssetRequest(input=self.input_settings, playback_policy=[mux_python.PlaybackPolicy.PUBLIC], mp4_support="standard") self.create_asset_response = self.assets_api.create_asset(self.create_asset_request)
#create an instance of the API class api_instance = mux_python.AssetsApi(mux_python.ApiClient(configuration)) with open('videosinfo.py', 'rb') as file: videos = pickle.loads(file.read()) print(videos) playback_ids = {} for name, url in videos.items(): temp_id = name start = temp_id.find('_') + 1 end = temp_id.find('.mp4', start) video_id = temp_id[start:end] print(video_id) create_asset_request = mux_python.CreateAssetRequest( input=url, playback_policy=["signed"], passthrough="yt_video_id:" + video_id) #create asset request print(create_asset_request) print(create_asset_request.input) try: #create an asset api_response = api_instance.create_asset(create_asset_request) print(api_response) d = vars(api_response.data) print(d) print(type(d)) id = d['_playback_ids']
# Authentication Setup configuration = mux_python.Configuration() configuration.username = os.environ['MUX_TOKEN_ID'] configuration.password = os.environ['MUX_TOKEN_SECRET'] # API Client Initialization assets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration)) # Create an asset input_settings = [ mux_python.InputSettings( url='https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4') ] create_asset_request = mux_python.CreateAssetRequest( input=input_settings, playback_policy=[mux_python.PlaybackPolicy.PUBLIC], mp4_support="standard") create_asset_response = assets_api.create_asset(create_asset_request) print("Created Asset ID: " + create_asset_response.data.id) # Wait for the asset to become ready, and then print its playback URL if create_asset_response.data.status != 'ready': print("Waiting for asset to become ready...") while True: asset_response = assets_api.get_asset(create_asset_response.data.id) if asset_response.data.status != 'ready': print("Asset still not ready. Status was: " + asset_response.data.status) time.sleep(1)
import mux_python from mux_python.rest import ApiException import logger # Exercises all direct upload operations. # Authentication Setup configuration = mux_python.Configuration() configuration.username = os.environ['MUX_TOKEN_ID'] configuration.password = os.environ['MUX_TOKEN_SECRET'] # API Client Initialization uploads_api = mux_python.DirectUploadsApi(mux_python.ApiClient(configuration)) # ========== create-direct-upload ========== create_asset_request = mux_python.CreateAssetRequest( playback_policy=[mux_python.PlaybackPolicy.PUBLIC]) create_upload_request = mux_python.CreateUploadRequest( timeout=3600, new_asset_settings=create_asset_request, cors_origin="philcluff.co.uk") create_upload_response = uploads_api.create_direct_upload( create_upload_request) logger.print_debug(str(create_upload_response)) assert create_upload_response != None assert create_upload_response.data != None assert create_upload_response.data.id != None print("create-direct-upload OK ✅") # ========== list-direct-uploads ========== list_direct_uploads_response = uploads_api.list_direct_uploads() logger.print_debug(str(list_direct_uploads_response))
# Exercises all asset operations. # Authentication Setup configuration = mux_python.Configuration() configuration.username = os.environ['MUX_TOKEN_ID'] configuration.password = os.environ['MUX_TOKEN_SECRET'] # API Client Initialization assets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration)) playback_ids_api = mux_python.PlaybackIDApi(mux_python.ApiClient(configuration)) # ========== create-asset ========== add_captions = mux_python.CreateTrackRequest(url="https://tears-of-steel-subtitles.s3.amazonaws.com/tears-fr.vtt", type="text", text_type="subtitles", language_code="fr", closed_captions=False, name="French") input_settings = [mux_python.InputSettings(url='https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4'), add_captions] create_asset_request = mux_python.CreateAssetRequest(input=input_settings) create_asset_response = assets_api.create_asset(create_asset_request) logger.print_debug("Created Asset: " + str(create_asset_response)) assert create_asset_response != None assert create_asset_response.data.id != None print("create-asset OK ✅") # ========== list-assets ========== list_assets_response = assets_api.list_assets() logger.print_debug ("Got List Asset Response: " + str(list_assets_response)) assert list_assets_response != None assert list_assets_response.data[0].id == create_asset_response.data.id print("list-assets OK ✅") # Wait for the asset to become ready... if create_asset_response.data.status != 'ready':
import logger # Authentication Setup configuration = mux_python.Configuration() configuration.username = os.environ['MUX_TOKEN_ID'] configuration.password = os.environ['MUX_TOKEN_SECRET'] # API Client Initialization assets_api = mux_python.AssetsApi(mux_python.ApiClient(configuration)) # ========== create-asset ========== add_captions = mux_python.CreateTrackRequest( url="https://tears-of-steel-subtitles.s3.amazonaws.com/tears-en.vtt", type="text", text_type="subtitles", language_code="en", closed_captions=False, name="English") input_settings = [ mux_python.InputSettings( url='https://storage.googleapis.com/muxdemofiles/mux-video-intro.mp4'), add_captions ] create_asset_request = mux_python.CreateAssetRequest( input=input_settings, playback_policy=mux_python.PlaybackPolicy.PUBLIC) create_asset_response = assets_api.create_asset(create_asset_request) logger.print_debug("Created Asset: " + str(create_asset_response)) assert create_asset_response != None assert create_asset_response.data.id != None print("create-asset OK ✅")