fixed "Can't play this video." bug.

This commit is contained in:
Christian Schabesberger 2015-12-20 13:26:12 +01:00
parent 9f618f6678
commit 18bc937958
2 changed files with 11 additions and 11 deletions

View file

@ -109,7 +109,7 @@ public class YoutubeSearchEngine implements SearchEngine {
Matcher m = p.matcher(resultItem.webpage_url); Matcher m = p.matcher(resultItem.webpage_url);
resultItem.id=m.group(1); resultItem.id=m.group(1);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); //e.printStackTrace();
} }
resultItem.title = dl.text(); resultItem.title = dl.text();

View file

@ -75,7 +75,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
} catch (Exception e) {//if this fails, the video is most likely not available. } catch (Exception e) {//if this fails, the video is most likely not available.
// Determining why is done later. // Determining why is done later.
videoInfo.videoAvailableStatus = VideoInfo.VIDEO_UNAVAILABLE; videoInfo.videoAvailableStatus = VideoInfo.VIDEO_UNAVAILABLE;
Log.d(TAG, "Could not load JSON data for Youtube video \""+pageUrl+"\". This most likely means the video is unavailable"); Log.e(TAG, "Could not load JSON data for Youtube video \""+pageUrl+"\". This most likely means the video is unavailable");
} }
//---------------------------------- //----------------------------------
@ -94,7 +94,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
} }
decryptionCode = loadDecryptionCode(playerUrl); decryptionCode = loadDecryptionCode(playerUrl);
} catch (Exception e){ } catch (Exception e){
Log.d(TAG, "Could not load decryption code for the Youtube service."); Log.e(TAG, "Could not load decryption code for the Youtube service.");
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -323,10 +323,10 @@ public class YoutubeVideoExtractor extends VideoExtractor {
} }
id = matchGroup1(pat, url); id = matchGroup1(pat, url);
if(!id.isEmpty()){ if(!id.isEmpty()){
Log.i(TAG, "string \""+url+"\" matches!"); //Log.i(TAG, "string \""+url+"\" matches!");
return id; return id;
} }
Log.i(TAG, "string \""+url+"\" does not match."); //Log.i(TAG, "string \""+url+"\" does not match.");
return ""; return "";
} }
@ -358,7 +358,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
int hours = (hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString)); int hours = (hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString));
int ret = seconds + (60*minutes) + (3600*hours);//don't trust BODMAS! int ret = seconds + (60*minutes) + (3600*hours);//don't trust BODMAS!
Log.d(TAG, "derived timestamp value:"+ret); //Log.d(TAG, "derived timestamp value:"+ret);
return ret; return ret;
//the ordering varies internationally //the ordering varies internationally
}//else, return default 0 }//else, return default 0
@ -513,8 +513,8 @@ public class YoutubeVideoExtractor extends VideoExtractor {
//this page causes the NullPointerException, after finding it by searching for "tjvg": //this page causes the NullPointerException, after finding it by searching for "tjvg":
//https://www.youtube.com/watch?v=Uqg0aEhLFAg //https://www.youtube.com/watch?v=Uqg0aEhLFAg
String views = li.select("span.view-count").first().text(); String views = li.select("span.view-count").first().text();
Log.i(TAG, "title:"+info.title); //Log.i(TAG, "title:"+info.title);
Log.i(TAG, "view count:"+views); //Log.i(TAG, "view count:"+views);
try { try {
info.view_count = Long.parseLong(li.select("span.view-count") info.view_count = Long.parseLong(li.select("span.view-count")
.first().text().replaceAll("[^\\d]", "")); .first().text().replaceAll("[^\\d]", ""));
@ -551,7 +551,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
try { try {
decryptionFuncName = matchGroup1("\\.sig\\|\\|([a-zA-Z0-9$]+)\\(", playerCode); decryptionFuncName = matchGroup1("\\.sig\\|\\|([a-zA-Z0-9$]+)\\(", playerCode);
String functionPattern = "(var "+ decryptionFuncName.replace("$", "\\$") +"=function\\([a-zA-Z0-9_]*\\)\\{.+?\\})"; String functionPattern = "(" + decryptionFuncName.replace("$", "\\$") +"=function\\([a-zA-Z0-9_]*\\)\\{.+?\\})";
decryptionFunc = matchGroup1(functionPattern, playerCode); decryptionFunc = matchGroup1(functionPattern, playerCode);
decryptionFunc += ";"; decryptionFunc += ";";
@ -565,7 +565,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
} }
callerFunc = callerFunc.replace("%%", decryptionFuncName); callerFunc = callerFunc.replace("%%", decryptionFuncName);
decryptionCode = helperObject + decryptionFunc + callerFunc; decryptionCode = helperObject + "var " + decryptionFunc + callerFunc;
return decryptionCode; return decryptionCode;
} }
@ -601,7 +601,7 @@ public class YoutubeVideoExtractor extends VideoExtractor {
return mat.group(1); return mat.group(1);
} }
else { else {
Log.w(TAG, "failed to find pattern \""+pattern+"\" inside of \""+input+"\""); Log.e(TAG, "failed to find pattern \""+pattern+"\" inside of \""+input+"\"");
new Exception("failed to find pattern \""+pattern+"\"").printStackTrace(); new Exception("failed to find pattern \""+pattern+"\"").printStackTrace();
return ""; return "";
} }