[YouTube] parse timestamps with >3 digits correctly (#775)

* [YouTube] parse timestamps with >3 digits correctly

Fixes https://github.com/TeamNewPipe/NewPipe/issues/7530; check the
issue for details.

* Remove outdated comment
This commit is contained in:
Mohammed Anas 2022-01-12 12:45:06 +03:00 committed by GitHub
parent 10f6cc7194
commit 65df39b3e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -302,7 +302,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
@Override
public long getTimeStamp() throws ParsingException {
final long timestamp =
getTimestampSeconds("((#|&|\\?)t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)");
getTimestampSeconds("((#|&|\\?)t=\\d*h?\\d*m?\\d+s?)");
if (timestamp == -2) {
// Regex for timestamp was not found

View file

@ -441,9 +441,9 @@ public abstract class StreamExtractor extends Extractor {
String minutesString = "";
String hoursString = "";
try {
secondsString = Parser.matchGroup1("(\\d{1,3})s", timeStamp);
minutesString = Parser.matchGroup1("(\\d{1,3})m", timeStamp);
hoursString = Parser.matchGroup1("(\\d{1,3})h", timeStamp);
secondsString = Parser.matchGroup1("(\\d+)s", timeStamp);
minutesString = Parser.matchGroup1("(\\d+)m", timeStamp);
hoursString = Parser.matchGroup1("(\\d+)h", timeStamp);
} catch (Exception e) {
//it could be that time is given in another method
if (secondsString.isEmpty() //if nothing was got,

View file

@ -112,8 +112,8 @@ public class YoutubeStreamExtractorDefaultTest {
public static class DescriptionTestPewdiepie extends DefaultStreamExtractorTest {
private static final String ID = "7PIMiDcwNvc";
private static final int TIMESTAMP = 17;
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP;
private static final int TIMESTAMP = 7483;
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP + "s";
private static StreamExtractor extractor;
@BeforeClass