1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-06-25 22:53:20 +00:00
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 {
// get next video
System.out.println(extractor.getUrlIdHandler());
StreamPreviewInfoCollector c = new StreamPreviewInfoCollector(
extractor.getUrlIdHandler(), extractor.getServiceId());
c.commit(extractor.getNextVideo());
if(c.getItemList().size() != 0) {
streamInfo.next_video = c.getItemList().get(0);
if(streamInfo.next_video != null)
{
StreamPreviewInfoCollector c = new StreamPreviewInfoCollector(
extractor.getUrlIdHandler(), extractor.getServiceId());
StreamPreviewInfoExtractor nextVideo = extractor.getNextVideo();
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);
}
try {

View File

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

View File

@ -36,7 +36,11 @@ public class YoutubeStreamUrlIdHandler implements StreamUrlIdHandler {
@SuppressWarnings("WeakerAccess")
@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;
if(url.contains("youtube")) {
@ -48,7 +52,12 @@ public class YoutubeStreamUrlIdHandler implements StreamUrlIdHandler {
} catch(UnsupportedEncodingException 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);
}
}