Skip to content

Commit

Permalink
handle youtube URLs with vid at arbitrary place
Browse files Browse the repository at this point in the history
  • Loading branch information
msram committed Oct 28, 2012
1 parent 85e1af7 commit 357a1e6
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions content/selectionManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,16 +316,28 @@ iitk.cse.cs213.bytubed.buildLinks = function buildLinks(contentDocument, links)

for(var i=0; i<anchors.length; i++)
{
if(anchors[i].href && iccb.isYouTubeLink(anchors[i].href))
if(anchors[i].href)
{
var vid = iccb.getVidsFromText(anchors[i].href)[0];

if(iccb.isValidVid(vid))
var vid = '';

if(iccb.isYouTubeLink(anchors[i].href))
{
vid = iccb.getVidsFromText(anchors[i].href)[0];
if(iccb.isValidVid(vid))
{
// Allow duplicates so that the getTitleAndDisplayTitle
// method can choose the best diplay title
links[links.length] = anchors[i]; // This is special
processedVids.push(vid);
}
}
else if(anchors[i].href.indexOf('youtube.com/watch?') != -1)
{
// Allow duplicates so that the getTitleAndDisplayTitle
// method can choose the best diplay title
links[links.length] = anchors[i]; // This is special
processedVids.push(vid);
// To deal with cases like the following:
// http://www.youtube.com/watch?feature=player_embedded&v=U6Z6_sc9mLE
// in which "v=" appears not after "watch?", but at some random place.
vid = iccb.getParamsFromUrl(anchors[i].href)['v'];
iccb.buildLinksForVids([vid], links, processedVids);
}
}
}
Expand Down

0 comments on commit 357a1e6

Please sign in to comment.