This commit is contained in:
David 2016-06-08 12:35:54 -03:00
parent ddc3b47dfa
commit 9d5951765f
3 changed files with 24 additions and 11 deletions

View file

@ -230,15 +230,19 @@ public class StreamInfo extends AbstractVideoInfo {
} }
try { try {
// get next video // get next video
System.out.println(extractor.getUrlIdHandler()); if(streamInfo.next_video != null)
StreamPreviewInfoCollector c = new StreamPreviewInfoCollector( {
extractor.getUrlIdHandler(), extractor.getServiceId()); StreamPreviewInfoCollector c = new StreamPreviewInfoCollector(
c.commit(extractor.getNextVideo()); extractor.getUrlIdHandler(), extractor.getServiceId());
if(c.getItemList().size() != 0) { StreamPreviewInfoExtractor nextVideo = extractor.getNextVideo();
streamInfo.next_video = c.getItemList().get(0); c.commit(nextVideo);
if(c.getItemList().size() != 0) {
streamInfo.next_video = c.getItemList().get(0);
}
streamInfo.errors.addAll(c.getErrors());
} }
streamInfo.errors.addAll(c.getErrors()); }
} catch(Exception e) { catch(Exception e) {
streamInfo.addException(e); streamInfo.addException(e);
} }
try { try {

View file

@ -56,7 +56,7 @@ public class StreamPreviewInfoCollector {
resultItem.webpage_url = extractor.getWebPageUrl(); resultItem.webpage_url = extractor.getWebPageUrl();
if (urlIdHandler == null) { if (urlIdHandler == null) {
throw new ParsingException("Error: UrlIdHandler not set"); throw new ParsingException("Error: UrlIdHandler not set");
} else { } else if(!resultItem.webpage_url.isEmpty()) {
resultItem.id = (new YoutubeStreamUrlIdHandler()).getVideoId(resultItem.webpage_url); resultItem.id = (new YoutubeStreamUrlIdHandler()).getVideoId(resultItem.webpage_url);
} }
resultItem.title = extractor.getTitle(); resultItem.title = extractor.getTitle();

View file

@ -36,7 +36,11 @@ public class YoutubeStreamUrlIdHandler implements StreamUrlIdHandler {
@SuppressWarnings("WeakerAccess") @SuppressWarnings("WeakerAccess")
@Override @Override
public String getVideoId(String url) throws ParsingException { public String getVideoId(String url) throws ParsingException, IllegalArgumentException {
if(url.isEmpty())
{
throw new IllegalArgumentException("The url parameter should not be empty");
}
String id; String id;
if(url.contains("youtube")) { if(url.contains("youtube")) {
@ -48,7 +52,12 @@ public class YoutubeStreamUrlIdHandler implements StreamUrlIdHandler {
} catch(UnsupportedEncodingException uee) { } catch(UnsupportedEncodingException uee) {
throw new ParsingException("Could not parse attribution_link", uee); throw new ParsingException("Could not parse attribution_link", uee);
} }
} else { }
else if(url.contains("vnd.youtube"))
{
id = Parser.matchGroup1("vnd.youtube\\:([\\-a-zA-Z0-9_]{11}).*", url);
}
else {
id = Parser.matchGroup1("[?&]v=([\\-a-zA-Z0-9_]{11})", url); id = Parser.matchGroup1("[?&]v=([\\-a-zA-Z0-9_]{11})", url);
} }
} }