Need help in youtube video bookmarklets - javascript

I'm making a web app and a bookmarklets for my website so that user can directly bookmark any video in their browser through any youtube video posted on my website.
hi anyone can help me to solve this for youtube video bookmarklets
I want to keep only youtube video ID in following code
javascript:(function(){window.open('http://example.com/bookmarklets/bookmark?id='+encodeURIComponent(location.href)+'')})();
Result should be : http://example.com/bookmarklets/bookmark?id=LIQZ6CjpHUA
but when i test above code i found that it takes whole youtube URL instead of youtube video ID
Instead of above result i got this : **http://example.com/bookmarklets/bookmark?id=https://www.youtube.com/watch?v=IUeqywml0SU
but i want only this result : http://example.com/bookmarklets/bookmark?IUeqywml0SU

I found the answers by myself...
here are the code
When we'll use this bookmarklet
javascript:(function(){window.open('http://example.com/download/'+encodeURIComponent(document.title)+'?id='+encodeURIComponent(location.href.replace('https://www.youtube.com/watch?v=', ''))+'')})();
For this youtube video
https://www.youtube.com/watch?v=GhQGm9d4e8c
We'll get this final output from URL:
GhQGm9d4e8c
Thanks

Related

Take screenshot of youtube video playing in iframe

I am embedding youtube on my web app and I want to take a screenshot of specific timestamp programmatically by js.
So that I can store images of in the DB.
I tried html2canvas but it is not working out, please help.

How to get file directory from webpage

currently i am creating chrome extension (video donwloader) and I am willing to get the video path
http://<IP ADDRESS>/video.mp4 from webpage where video is. and also in some websites they are using iframes to display the video and i also need to get the video from that url of iframe, here is one scenario: website is using another website for the video for example: example.com has a video on link example.com/video/ID/312351 and video source on videos.example.com/id/31312/video.mp4 and secondexample.com is using example.com/video/ID/312351 url in iframe to get the video, and when i am on secondexample.com i also need to get the video source (videos.example.com/id/31312/video.mp4) from example.com, Is this possible? and how. Thank You!

Youtube Iframe Api get video title

I am using the youtube iframe api to embed newest uploaded videos from a youtube channel onto my webpage. I am successfully able to do this; however, I need to get the title of each video as well and display it within the html next to each video. So far, I cannot find a solution to do so.
This is my code to retrieve one video. I am using this method so that I can embed the videos within a carousel that I have made, with each embedded video fetching the next latest upload (a different index from the same playlist).
<iframe width="300" height="300" src="http://www.youtube.com/embed?autoplay=0&max-results=1&controls=0&showinfo=1&rel=0&listType=user_uploads&list=channelName&index=0" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
Can anyone provide me with some tips on how to obtain the title (and possibly other information related to the video such as a date)?
All help is greatly appreciated!
Thank You!
-TT
With the new YouTube API there's no way to do this using Javscript or jQuery. However, there seems to be solutions that use PHP:
Solution Using PHP
If you're not comfortable with PHP and/or you're not uploading a lot of YouTube Videos, I would suggest either hard-coding the titles into your HTML or creating a column(s) in your database for the relevant information.

youtube iframe player - javascript to change playlist

does anyone know how and what javascript to use to change the playlist of a iframe youtube player?
I have searched the net but can't seem to find a simple piece of code for it.
I believe you're looking for the loadPlaylist() function of the YouTube Player API.

Get YouTube Audio URL on iOS

I am using this javascript code to get a downloadable video URL from the mobile youtube website.
[webView stringByEvaluatingJavaScriptFromString:#"function getURL() {var player = document.getElementById('player'); var video = player.getElementsByTagName('video')[0]; return video.getAttribute('src');} getURL();"];
Output URL: http://o-o.preferred.seabone-mil1.v22.nonxt2.c.youtube.com/videoplayback?el=results&begin=0&yms=5682703339584930992&itag=18&ip=87.0.0.0&app=youtube_mobile&signature=B8CD6B60D2609F5F137B885806F8FAECAA88492F.333D3F19876A77CECB264059A3852BD021401296&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Csource%2Cratebypass%2Ccp&len=254000&ratebypass=yes&source=youtube&expire=1323579819&sver=3&key=yt1&ipbits=8&cp=U0hRSFVSV19GU0NOMV9NTEFJOmV5Qk5wc3hWaUxG&id=b8e73777013e0b7e&ps=blazer
I would like to do the same with just the audio of the video. But i haven't succeeded yet. Can anyone help me?
I solved it! I use the youtube-mp3.org api which works really good. there are some questions about it on SO with good answers!
It's going to be difficult to extract the audio only portions from an existing video from within iOS. I'm sure there are libs out there that can help, but I think it's going to be an involved topic.
Perhaps you can take a look at Display YouTube Videos Without Exiting Your Application. It describes ways to play youtube videos from within your iOS application. Now if you do something similar but set the view to be hidden, you would be able to "listen" to the youtube videos's audio without showing the video itself on the screen.
I don't know what the end-goal is for you're application, but perhaps my suggestion will be food-for-thought.

Categories