mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-27 23:40:36 +05:30
[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:
parent
10f6cc7194
commit
65df39b3e3
@ -302,7 +302,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
@Override
|
@Override
|
||||||
public long getTimeStamp() throws ParsingException {
|
public long getTimeStamp() throws ParsingException {
|
||||||
final long timestamp =
|
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) {
|
if (timestamp == -2) {
|
||||||
// Regex for timestamp was not found
|
// Regex for timestamp was not found
|
||||||
|
@ -441,9 +441,9 @@ public abstract class StreamExtractor extends Extractor {
|
|||||||
String minutesString = "";
|
String minutesString = "";
|
||||||
String hoursString = "";
|
String hoursString = "";
|
||||||
try {
|
try {
|
||||||
secondsString = Parser.matchGroup1("(\\d{1,3})s", timeStamp);
|
secondsString = Parser.matchGroup1("(\\d+)s", timeStamp);
|
||||||
minutesString = Parser.matchGroup1("(\\d{1,3})m", timeStamp);
|
minutesString = Parser.matchGroup1("(\\d+)m", timeStamp);
|
||||||
hoursString = Parser.matchGroup1("(\\d{1,3})h", timeStamp);
|
hoursString = Parser.matchGroup1("(\\d+)h", timeStamp);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//it could be that time is given in another method
|
//it could be that time is given in another method
|
||||||
if (secondsString.isEmpty() //if nothing was got,
|
if (secondsString.isEmpty() //if nothing was got,
|
||||||
|
@ -112,8 +112,8 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||||||
|
|
||||||
public static class DescriptionTestPewdiepie extends DefaultStreamExtractorTest {
|
public static class DescriptionTestPewdiepie extends DefaultStreamExtractorTest {
|
||||||
private static final String ID = "7PIMiDcwNvc";
|
private static final String ID = "7PIMiDcwNvc";
|
||||||
private static final int TIMESTAMP = 17;
|
private static final int TIMESTAMP = 7483;
|
||||||
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP;
|
private static final String URL = BASE_URL + ID + "&t=" + TIMESTAMP + "s";
|
||||||
private static StreamExtractor extractor;
|
private static StreamExtractor extractor;
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
|
Loading…
x
Reference in New Issue
Block a user