History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: LPP-5424
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: -- --
Assignee: Unassigned
Reporter: Mamye Kratt
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
OpenLaszlo

YouTube demo is broken, clicking on picture does not load video

Created: 12/Feb/08 12:57 PM   Updated: 04/Mar/08 04:20 PM
Component/s: SA - General
Affects Version/s: RingDing (4.1), DevilDog, Freya
Fix Version/s: RingDing (4.1), Freya

Time Tracking:
Not Specified

Environment:
XP FF2
OS X FF2

Severity: Minor
Fixed in Change#: 8,021
Runtime: N/A
Fix in hand: False


 Description  « Hide
(pagan-deities build r7986)
Clicking on picture does not load the video. Search feature works.

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Max Carlson - 13/Feb/08 06:14 PM
Author: max
Date: 2008-02-13 17:33:32 -0800 (Wed, 13 Feb 2008)
New Revision: 8021

Modified:
   openlaszlo/trunk/demos/youtube/youtube.jsp
   openlaszlo/trunk/demos/youtube/youtube.lzx
Log:
Change 20080213-maxcarlson-o by maxcarlson@Roboto on 2008-02-13 15:13:18 PST
    in /Users/maxcarlson/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: Fix youtube video loading, for real this time!

New Features:

Bugs Fixed: LPP-5424 - YouTube demo is broken, clicking on picture does not load video

Technical Reviewer: promanik
QA Reviewer: mkratt
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: youtube.jsp - Parse out Location header from different URL - totally bulletproof now.

youtube.lzx - Proxied loads are no longer supported/required!
    

Tests: Any video will play in youtube.lzx now.



Modified: openlaszlo/trunk/demos/youtube/youtube.jsp
===================================================================
--- openlaszlo/trunk/demos/youtube/youtube.jsp 2008-02-14 00:40:55 UTC (rev 8020)
+++ openlaszlo/trunk/demos/youtube/youtube.jsp 2008-02-14 01:33:32 UTC (rev 8021)
@@ -11,7 +11,7 @@
 <%!
 
 /* X_LZ_COPYRIGHT_BEGIN ****************************************************
- * Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
+ * Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
  * Use is subject to license terms. *
  * X_LZ_COPYRIGHT_END ******************************************************/
 
@@ -199,18 +199,22 @@
         Document result)
     {
         String pageUrl =
- "http://www.YouTube.com/watch?v=";
- pageUrl += id;
+ "http://www.youtube.com/v/" + id;
 
- BufferedReader inputFile = null;
+ // Based on http://www.jeroenwijering.com/?thread=5484#msg50818
+ // Get Location header and parse strings from that...
+ String redirURL = null;
         try {
             URL u = new URL(pageUrl);
- inputFile =
- new BufferedReader(
- new InputStreamReader(
- u.openStream()));
+ HttpURLConnection redir = (java.net.HttpURLConnection)u.openConnection();
+ redir.setFollowRedirects(false);
+ redir.connect();
+ redirURL = redir.getHeaderField("Location");
+ if (redirURL == null) {
+ throw new Exception("No Location header found");
+ }
         } catch (Exception e) {
- reportError("Could not load url.", result);
+ reportError("Could not load url " + redirURL + ": " + e.toString(), result);
             return;
         } // try
 
@@ -219,57 +223,34 @@
 
         String videoId = "";
         String tId = "";
- while (true) {
- String line = null;
 
- try {
- line = inputFile.readLine();
- } catch (IOException e) {
- line = null;
- }
-
- if (line == null) {
- break;
- }
-
- int start =
- line.indexOf("swfArgs");
- if (start == -1) {
- continue;
- } else {
- // Extract the video_id from the args line
- Pattern vidpat = Pattern.compile("video_id:'[\\w\\d]+'?");
- Pattern tpat = Pattern.compile("t:'[\\w\\d]+'?");
- Matcher vidmatcher = vidpat.matcher(line);
- Matcher tmatcher = tpat.matcher(line);
- if ( vidmatcher.find() ) {
- videoId = (line.substring(vidmatcher.start(), vidmatcher.end()));
- videoId = videoId.substring(10, videoId.length()-1);
- } else {
- reportError("video_id argument not found in HTML page", result);
- return;
- }
- if ( tmatcher.find() ) {
- tId = (line.substring(tmatcher.start(), tmatcher.end()));
- tId = tId.substring(3, tId.length()-1);
- } else {
- reportError("t argument not found in HTML page", result);
- return;
- }
- }
-
- String url =
- "http://www.youtube.com/get_video?video_id=" + videoId + "&t=" + tId;
-
- resultEl.setAttribute("id", videoId);
- resultEl.setAttribute("t", tId);
- resultEl.setAttribute("url", url);
- result.setRootElement(resultEl);
-
+ // Extract the video_id and t fields from
+ Pattern vidpat = Pattern.compile("video_id=[\\w\\d]+'?");
+ Pattern tpat = Pattern.compile("t=[\\w\\d\\-]+'?");
+ Matcher vidmatcher = vidpat.matcher(redirURL);
+ Matcher tmatcher = tpat.matcher(redirURL);
+ if ( vidmatcher.find() ) {
+ videoId = (redirURL.substring(vidmatcher.start(), vidmatcher.end()));
+ videoId = videoId.substring(9, videoId.length());
+ } else {
+ reportError("video_id argument not found in HTML page", result);
             return;
         }
+ if ( tmatcher.find() ) {
+ tId = (redirURL.substring(tmatcher.start(), tmatcher.end()));
+ tId = tId.substring(2, tId.length());
+ } else {
+ reportError("t argument not found in URL", result);
+ return;
+ }
 
- reportError("Could not find SWFObject at url " + pageUrl, result);
+ String url =
+ "http://www.youtube.com/get_video?video_id=" + videoId + "&t=" + tId;
+
+ resultEl.setAttribute("id", videoId);
+ resultEl.setAttribute("t", tId);
+ resultEl.setAttribute("url", url);
+ result.setRootElement(resultEl);
     }
 
 

Modified: openlaszlo/trunk/demos/youtube/youtube.lzx
===================================================================
--- openlaszlo/trunk/demos/youtube/youtube.lzx 2008-02-14 00:40:55 UTC (rev 8020)
+++ openlaszlo/trunk/demos/youtube/youtube.lzx 2008-02-14 01:33:32 UTC (rev 8021)
@@ -1,5 +1,5 @@
 <!-- X_LZ_COPYRIGHT_BEGIN ************************************************
-* Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
 * Use is subject to license terms. *
 * X_LZ_COPYRIGHT_END ************************************************** -->
 
@@ -7,7 +7,6 @@
 <canvas
   width="100%"
   height="100%"
- proxied="true"
 >
     
     <include href="av/videoutils.lzx"/>


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Max Carlson - 19/Feb/08 12:47 PM
Also fixed in pagan/4.0.10 r8063:

Author: max
Date: 2008-02-19 12:43:39 -0800 (Tue, 19 Feb 2008)
New Revision: 8063

Modified:
   openlaszlo/branches/pagan-deities/
   openlaszlo/branches/pagan-deities/demos/youtube/youtube.jsp
   openlaszlo/branches/pagan-deities/demos/youtube/youtube.lzx
Log:
Merged revisions 8021 via svnmerge from
http://svn.openlaszlo.org/openlaszlo/trunk

.......
  r8021 | max | 2008-02-13 17:33:32 -0800 (Wed, 13 Feb 2008) | 26 lines
  
  Change 20080213-maxcarlson-o by maxcarlson@Roboto on 2008-02-13 15:13:18 PST
      in /Users/maxcarlson/openlaszlo/trunk
      for http://svn.openlaszlo.org/openlaszlo/trunk
  
  Summary: Fix youtube video loading, for real this time!
  
  New Features:
  
  Bugs Fixed: LPP-5424 - YouTube demo is broken, clicking on picture does not load video
  
  Technical Reviewer: promanik
  QA Reviewer: mkratt
  Doc Reviewer: (pending)
  
  Documentation:
  
  Release Notes:
  
  Details: youtube.jsp - Parse out Location header from different URL - totally bulletproof now.
  
  youtube.lzx - Proxied loads are no longer supported/required!
      
  
  Tests: Any video will play in youtube.lzx now.
.......



Property changes on: openlaszlo/branches/pagan-deities
___________________________________________________________________
Name: svnmerge-integrated
   - /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-7950,7983
   + /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7135,7137-7235 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097,7872 /openlaszlo/trunk:1-7950,7983,8021

Modified: openlaszlo/branches/pagan-deities/demos/youtube/youtube.jsp
===================================================================
--- openlaszlo/branches/pagan-deities/demos/youtube/youtube.jsp 2008-02-19 20:40:46 UTC (rev 8062)
+++ openlaszlo/branches/pagan-deities/demos/youtube/youtube.jsp 2008-02-19 20:43:39 UTC (rev 8063)
@@ -11,7 +11,7 @@
 <%!
 
 /* X_LZ_COPYRIGHT_BEGIN ****************************************************
- * Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
+ * Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
  * Use is subject to license terms. *
  * X_LZ_COPYRIGHT_END ******************************************************/
 
@@ -199,18 +199,22 @@
         Document result)
     {
         String pageUrl =
- "http://www.YouTube.com/watch?v=";
- pageUrl += id;
+ "http://www.youtube.com/v/" + id;
 
- BufferedReader inputFile = null;
+ // Based on http://www.jeroenwijering.com/?thread=5484#msg50818
+ // Get Location header and parse strings from that...
+ String redirURL = null;
         try {
             URL u = new URL(pageUrl);
- inputFile =
- new BufferedReader(
- new InputStreamReader(
- u.openStream()));
+ HttpURLConnection redir = (java.net.HttpURLConnection)u.openConnection();
+ redir.setFollowRedirects(false);
+ redir.connect();
+ redirURL = redir.getHeaderField("Location");
+ if (redirURL == null) {
+ throw new Exception("No Location header found");
+ }
         } catch (Exception e) {
- reportError("Could not load url.", result);
+ reportError("Could not load url " + redirURL + ": " + e.toString(), result);
             return;
         } // try
 
@@ -219,57 +223,34 @@
 
         String videoId = "";
         String tId = "";
- while (true) {
- String line = null;
 
- try {
- line = inputFile.readLine();
- } catch (IOException e) {
- line = null;
- }
-
- if (line == null) {
- break;
- }
-
- int start =
- line.indexOf("swfArgs");
- if (start == -1) {
- continue;
- } else {
- // Extract the video_id from the args line
- Pattern vidpat = Pattern.compile("video_id:'[\\w\\d]+'?");
- Pattern tpat = Pattern.compile("t:'[\\w\\d]+'?");
- Matcher vidmatcher = vidpat.matcher(line);
- Matcher tmatcher = tpat.matcher(line);
- if ( vidmatcher.find() ) {
- videoId = (line.substring(vidmatcher.start(), vidmatcher.end()));
- videoId = videoId.substring(10, videoId.length()-1);
- } else {
- reportError("video_id argument not found in HTML page", result);
- return;
- }
- if ( tmatcher.find() ) {
- tId = (line.substring(tmatcher.start(), tmatcher.end()));
- tId = tId.substring(3, tId.length()-1);
- } else {
- reportError("t argument not found in HTML page", result);
- return;
- }
- }
-
- String url =
- "http://www.youtube.com/get_video?video_id=" + videoId + "&t=" + tId;
-
- resultEl.setAttribute("id", videoId);
- resultEl.setAttribute("t", tId);
- resultEl.setAttribute("url", url);
- result.setRootElement(resultEl);
-
+ // Extract the video_id and t fields from
+ Pattern vidpat = Pattern.compile("video_id=[\\w\\d]+'?");
+ Pattern tpat = Pattern.compile("t=[\\w\\d\\-]+'?");
+ Matcher vidmatcher = vidpat.matcher(redirURL);
+ Matcher tmatcher = tpat.matcher(redirURL);
+ if ( vidmatcher.find() ) {
+ videoId = (redirURL.substring(vidmatcher.start(), vidmatcher.end()));
+ videoId = videoId.substring(9, videoId.length());
+ } else {
+ reportError("video_id argument not found in HTML page", result);
             return;
         }
+ if ( tmatcher.find() ) {
+ tId = (redirURL.substring(tmatcher.start(), tmatcher.end()));
+ tId = tId.substring(2, tId.length());
+ } else {
+ reportError("t argument not found in URL", result);
+ return;
+ }
 
- reportError("Could not find SWFObject at url " + pageUrl, result);
+ String url =
+ "http://www.youtube.com/get_video?video_id=" + videoId + "&t=" + tId;
+
+ resultEl.setAttribute("id", videoId);
+ resultEl.setAttribute("t", tId);
+ resultEl.setAttribute("url", url);
+ result.setRootElement(resultEl);
     }
 
 

Modified: openlaszlo/branches/pagan-deities/demos/youtube/youtube.lzx
===================================================================
--- openlaszlo/branches/pagan-deities/demos/youtube/youtube.lzx 2008-02-19 20:40:46 UTC (rev 8062)
+++ openlaszlo/branches/pagan-deities/demos/youtube/youtube.lzx 2008-02-19 20:43:39 UTC (rev 8063)
@@ -1,5 +1,5 @@
 <!-- X_LZ_COPYRIGHT_BEGIN ************************************************
-* Copyright 2007 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2007, 2008 Laszlo Systems, Inc. All Rights Reserved. *
 * Use is subject to license terms. *
 * X_LZ_COPYRIGHT_END ************************************************** -->
 
@@ -7,7 +7,6 @@
 <canvas
   width="100%"
   height="100%"
- proxied="true"
 >
     
     <include href="av/videoutils.lzx"/>


_______________________________________________
Laszlo-checkins mailing list
Laszlo-checkins@openlaszlo.org
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Mamye Kratt - 20/Feb/08 12:28 PM
(pagan deities build r8066 freya 4.0.10)
YouTube plays when picture is selected.

Mamye Kratt - 20/Feb/08 12:29 PM
Retest in trunk for ringding.

Mamye Kratt - 04/Mar/08 04:20 PM
(trunk build r8155)
YouTube demo is working again.