mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2025-01-11 09:50:32 +00:00
fixed another parsing but related to livestreams
This commit is contained in:
parent
f90a163ede
commit
19418e5dfb
@ -216,8 +216,15 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||||||
return YoutubeParsingHelper.parseDurationString(
|
return YoutubeParsingHelper.parseDurationString(
|
||||||
item.select("span[class=\"video-time\"]").first().text());
|
item.select("span[class=\"video-time\"]").first().text());
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
|
if(isLiveStream(item)) {
|
||||||
|
// -1 for no duration
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
throw new ParsingException("Could not get Duration", e);
|
throw new ParsingException("Could not get Duration", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -245,9 +252,21 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||||||
@Override
|
@Override
|
||||||
public long getViewCount() throws ParsingException {
|
public long getViewCount() throws ParsingException {
|
||||||
String output;
|
String output;
|
||||||
String input = item.select("div[class=\"yt-lockup-meta\"]").first()
|
String input;
|
||||||
|
try {
|
||||||
|
input = item.select("div[class=\"yt-lockup-meta\"]").first()
|
||||||
.select("li").get(1)
|
.select("li").get(1)
|
||||||
.text();
|
.text();
|
||||||
|
} catch (IndexOutOfBoundsException e) {
|
||||||
|
if(isLiveStream(item)) {
|
||||||
|
// -1 for no view count
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
throw new ParsingException(
|
||||||
|
"Could not parse yt-lockup-meta although available", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
output = Parser.matchGroup1("([0-9,\\. ]*)", input)
|
output = Parser.matchGroup1("([0-9,\\. ]*)", input)
|
||||||
.replace(" ", "")
|
.replace(" ", "")
|
||||||
.replace(".", "")
|
.replace(".", "")
|
||||||
@ -283,6 +302,11 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||||||
throw new ParsingException("Could not get thumbnail url", e);
|
throw new ParsingException("Could not get thumbnail url", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isLiveStream(Element item) {
|
||||||
|
Element bla = item.select("span[class*=\"yt-badge-live\"]").first();
|
||||||
|
return bla != null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user