Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
My comments usage uppon method Comments example
# This module generate methods to generate video's fluxes
# before signing it and request it.
module DMCloud
class Streaming
# Get media url for direct link to the file on DailyMotion Cloud
# Params :
# media_id: this is the id of the media (eg: 4c922386dede830447000009)
# asset_name: the name of the asset you want to stream (eg: mp4_h264_aac)
# asset_extension: the extension of the asset, most of the time it is the first part of the asset name (eg: mp4)
# Result :
# return a string which contain the signed url like
def self.url(media_id, asset_name, asset_extension = nil)
asset_extension = asset_name.split('_').first unless asset_extension
raise StandardError, "missing :media_id in params" unless media_id
raise StandardError, "missing :asset_name in params" unless asset_name
# Convert tags to values and sign_url
stream.gsub!('[PROTOCOL]', DMCloud.config[:protocol])
stream.gsub!('[USER_ID]', DMCloud.config[:user_key])
stream.gsub!('[MEDIA_ID]', media_id)
stream.gsub!('[ASSET_NAME]', asset_name)
stream.gsub!('[ASSET_EXTENSION]', asset_extension)
stream += '?auth=[AUTH_TOKEN]'.gsub!('[AUTH_TOKEN]', DMCloud::Signing.sign(stream))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment