Fix for #310
This commit is contained in:
parent
ddc3b47dfa
commit
9d5951765f
|
@ -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(
|
StreamPreviewInfoCollector c = new StreamPreviewInfoCollector(
|
||||||
extractor.getUrlIdHandler(), extractor.getServiceId());
|
extractor.getUrlIdHandler(), extractor.getServiceId());
|
||||||
c.commit(extractor.getNextVideo());
|
StreamPreviewInfoExtractor nextVideo = extractor.getNextVideo();
|
||||||
|
c.commit(nextVideo);
|
||||||
if(c.getItemList().size() != 0) {
|
if(c.getItemList().size() != 0) {
|
||||||
streamInfo.next_video = c.getItemList().get(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 {
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue