mirror of
https://github.com/TeamNewPipe/NewPipe.git
synced 2024-11-22 11:02:35 +01:00
Fix for #310
This commit is contained in:
parent
ddc3b47dfa
commit
9d5951765f
@ -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 {
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user