From: <die...@us...> - 2010-02-03 08:46:13
|
Revision: 1781 http://openutils.svn.sourceforge.net/openutils/?rev=1781&view=rev Author: diego_schivo Date: 2010-02-03 08:46:07 +0000 (Wed, 03 Feb 2010) Log Message: ----------- MEDIA-67 video-token retrieved from http://www.youtube.com/get_video_info instead of provided video-url Modified Paths: -------------- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java Modified: trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java =================================================================== --- trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java 2010-02-03 08:01:17 UTC (rev 1780) +++ trunk/openutils-mgnlmedia/src/main/java/net/sourceforge/openutils/mgnlmedia/media/types/impl/ExternalVideoTypeHandler.java 2010-02-03 08:46:07 UTC (rev 1781) @@ -164,23 +164,26 @@ try { String videoUrl = getUrl(media); - URL url = new URL(videoUrl); + String videoId = getVideoId(StringUtils.substringAfter(videoUrl, "?")); + String videoInfoUrl = "http://www.youtube.com/get_video_info?video_id=" + videoId; + URL url = new URL(videoInfoUrl); HttpURLConnection httpConn = (HttpURLConnection) url.openConnection(); if (httpConn.getResponseCode() == 200) { in = new BufferedReader(new InputStreamReader(httpConn.getInputStream())); String line; - String search = "\"t\""; + String search = "&token="; while ((line = in.readLine()) != null) { int p = line.indexOf(search); if (p != -1) { - String signature = StringUtils.substringBetween(line.substring(p + search.length()), "\"", "\""); + String token = StringUtils.substringBefore(line.substring(p + search.length()), "&"); flvUrl = "http://www.youtube.com/get_video?fmt=5&video_id=" - + getVideoId(StringUtils.substringAfter(videoUrl, "?")) + + videoId + "&t=" - + signature; + + token; + break; } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |