Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ public long getLength() throws ParsingException {
@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ protected long getTimestampSeconds(String regexPattern) throws ParsingException
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public void youtubeMusicPremiumContent() throws Exception {

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
Expand Down