Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
astromo
Visitor

Youtube contents in a private channel ?

Hello All,

I plan to make a private channel. Some of contents are from youtube. Is it possible technically and legal to include Youtube contents in a private channel. Thanks.
0 Kudos
17 REPLIES 17
bking007
Visitor

Re: Youtube contents in a private channel ?

I believe it is very much legal to create a private channel that include your own videos.
0 Kudos
gonzotek
Visitor

Re: Youtube contents in a private channel ?

"bking007" wrote:
I believe it is very much legal to create a private channel that include your own videos.
Legal, yes. However it might be a violation of the YouTube Terms of Service to use their hosting in a manner not approved by them. They give the hosting away for free because they can attach ads to videos displayed on the website and embedded on other sites. Some devices, like Apple TV, display Youtube without ads, but my understanding is this is possible because the device manufacturer had negotiated a contract with Google to pay for access to it.
Remoku.tv - A free web app for Roku Remote Control!
Want to control your Roku from nearly any phone, computer or tablet? Get started at http://help.remoku.tv
by Apps4TV - Applications for television and beyond: http://www.apps4tv.com
0 Kudos
astromo
Visitor

Re: Youtube contents in a private channel ?

Thank you. I intend to develop a channel as a library of my media (some are video files but some have been shared on Youtube). Please suggest me the command or script that I should start with to insert the youtube link in the private channel.
0 Kudos
timber03
Visitor

Re: Youtube contents in a private channel ?

astromo, I have a channel in development that will do just that. I hope to make it available for beta testing in the coming weeks.
Channels created
--------------------
REDBULLTV - RedBull's online sports channel. All sports, all the time.
JTV - Jewelry TV

Other Projects/Creations
-----------------------------
http://www.socialnetworkinc.com - Your Community. Connected.
0 Kudos
astromo
Visitor

Re: Youtube contents in a private channel ?

What is a basic script to add the content in the videoscreen? And what is the URL to be used for pointing to youtube contents?
0 Kudos
sftv
Visitor

Re: Youtube contents in a private channel ?

"astromo" wrote:
What is a basic script to add the content in the videoscreen? And what is the URL to be used for pointing to youtube contents?
0 Kudos
belltown
Roku Guru

Re: Youtube contents in a private channel ?

"astromo" wrote:
And what is the URL to be used for pointing to youtube contents?


You could try this function:


'**********************************************************************************************************************
' ytGetMP4Url - Retrieve a list of MP4 urls from YouTube for the specified video id
'
' Example usage:
'
' videoId = "S2wAMaM2OYQ" ' (required) YouTube Video Id
' ' Alternatively, the full Url of the YouTube video may be specified here
' timeout = 60000 ' (optional) Timeout in milliseconds (default: 0 => wait forever)
' loginCookie = "" ' (optional) YouTube login cookie - only required if video requires a login,
' ' e.g. Private or R-Rated videos (default: "")
' ' The login cookie can be obtained by calling ytLoginYouTube
' mp4VideoList = ytGetMP4Url (videoId, timeout, loginCookie)
' if mp4VideoList <> Invalid ' Invalid returned if no MP4 streams detected
' sdUrl = mp4VideoList.sdUrl
' hdUrl = mp4VideoList.hdUrl ' Will be empty string if no HD MP4 found
' hd1080pUrl = mp4VideoList.hd1080pUrl ' Will be empty string if no 1080p MP4 found
' hlsUrl = mp4VideoList.hlsUrl ' If an HLS stream is found, set to its index file's Url
' endif
'**********************************************************************************************************************
function ytGetMP4Url (videoIdOrUrl as string, timeout = 0 as integer, loginCookie = "" as string) as object
mp4VideoList = {sdUrl: "", hdUrl: "", hd1080pUrl: "", hlsUrl: ""}
if Left (LCase (videoIdOrUrl), 4) = "http"
url = videoIdOrUrl
else
url = "http://www.youtube.com/get_video_info?hl=en&el=detailpage&video_id=" + videoIdOrUrl
endif

'
' Get the web page containing video information
'
htmlString = ""
port = CreateObject ("roMessagePort")
ut = CreateObject ("roUrlTransfer")
ut.SetPort (port)
ut.AddHeader ("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:35.0) Gecko/20100101 Firefox/35.0 (gzip)")
if loginCookie <> ""
ut.AddHeader ("Cookie", loginCookie)
endif
ut.SetCertificatesFile ("common:/certs/ca-bundle.crt")
ut.InitClientCertificates ()
ut.EnableEncodings (true)
ut.SetUrl (url)
if ut.AsyncGetToString ()
while true
msg = Wait (timeout, port)
if type (msg) = "roUrlEvent"
status = msg.GetResponseCode ()
print "ytGetMP4Url. MP4 Url Request: Url = " + url + ". status = " + status.ToStr () + ". failureReason = " + msg.GetFailureReason ()
if status = 200
htmlString = msg.GetString ()
print "htmlString=" + htmlString
endif
exit while
else if type (msg) = "Invalid"
ut.AsyncCancel ()
print "ytGetMP4Url. Timeout"
exit while
endif
end while
endif

'
' urlEncodedFmtStreamMap contains any mp4 urls
' TODO: Check if 1080p support has been discontinued
'
urlEncodedFmtStreamMap = CreateObject ("roRegex", "\x22url_encoded_fmt_stream_map\x22:\x22([^\x22]+)\x22", "").Match (htmlString)
if urlEncodedFmtStreamMap.Count () > 1
commaSplit = CreateObject ("roRegex", ",", "").Split (urlEncodedFmtStreamMap [1])
for each commaItem in commaSplit
maVideoUrl = CreateObject ("roRegex", "url=(.+)", "").Match (commaItem)
if maVideoUrl.Count () = 2
videoUrl = ut.Unescape (maVideoUrl [1])
print "videoUrl: " + videoUrl
pair = {itag: ""}
ampersandSplit = CreateObject ("roRegex", "&", "").Split (videoUrl)
for each ampersandItem in ampersandSplit
equalsSplit = CreateObject ("roRegex", "=", "").Split (ampersandItem)
if equalsSplit.Count () = 2
pair [equalsSplit [0]] = equalsSplit [1]
endif
end for
if Left (LCase (videoUrl), 4) = "http"
urlDecoded = ut.Unescape (videoUrl)
if pair.itag = "18"
mp4VideoList.sdUrl = urlDecoded
else if pair.itag = "22"
mp4VideoList.hdUrl = urlDecoded
else if pair.itag = "37"
mp4VideoList.hd1080pUrl = urlDecoded
endif
endif
endif
end for
endif

'
' If no mp4 urls, check for live (HLS) feed in the hlsvp attribute
'
if mp4VideoList.sdUrl = "" and mp4VideoList.hdUrl = "" and mp4VideoList.hd1080pUrl = ""
' If no mp4 video streams were found, search for a live stream HLS manifest (.m3u8) file
hlsvp = CreateObject ("roRegex", "hlsvp=([^(" + Chr(34) + "|&|$)]*)", "").Match (htmlString)
if hlsvp.Count () > 1
hlsUrlDecoded = ut.Unescape (ut.Unescape (hlsvp [1]))
mp4VideoList.hlsUrl = hlsUrlDecoded
endif
if mp4VideoList.hlsUrl = ""
mp4VideoList = Invalid
endif
endif

if mp4VideoList <> invalid
print "ytGetMP4Url. sdUrl=" + mp4VideoList.sdUrl
print "ytGetMP4Url. hdUrl=" + mp4VideoList.hdUrl
print "ytGetMP4Url. hd1080pUrl=" + mp4VideoList.hd1080pUrl
print "ytGetMP4Url. hlsUrl=" + mp4VideoList.hlsUrl
else
print "ytGetMP4Url. No Video Streams Found"
endif

return mp4VideoList
end function
0 Kudos
astromo
Visitor

Re: Youtube contents in a private channel ?

belltown, thank you so much. I can start from there.
0 Kudos
buenafe
Visitor

Re: Youtube contents in a private channel ?

Belltown, ditto. Thanks. I've been pounding my head trying to understand how other channels did this. I'm trying to go to the next step. I'm trying to integrate your function to the simplevideoplayer.


Function displayVideo(args As Dynamic)
....
url = "http://youtu.be/nGeKSiCQkPw" ' The URL for the video
mp4Urls = getMP4Url (url) ' Get a list of all MP4 URLs
sdUrl = mp4Urls.sdUrl
....
'Swap the commented values below to play different video clips...
urls = [ sdUrl ]
qualities = ["SD"]
StreamFormat = "mp4"
....etc.



I get a bug when running this. (I don't have Roku access while I type this message - I'll update this post later).

I did notice that the generated sdUrl variable seems to be correct because I can cut-and-paste the URL to a web-browser to test.

I do notice that the URL contains ampersands "&" . Do I need to replace these with "&amp;" i nthe brightscript code?
----------------------------------------------------------------------------------
current: two roku XDS 2xs, dtvpal, boxeebox, kylo.tv,
radar: wdlxtv.com
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.