File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -142,9 +142,10 @@ public static long parseDurationString(String input)
142142 default :
143143 throw new ParsingException ("Error duration string with unknown format: " + input );
144144 }
145- return ((((Long .parseLong (Utils .removeNonDigitCharacters (days )) * 24 )
146- + Long .parseLong (Utils .removeNonDigitCharacters (hours )) * 60 )
147- + Long .parseLong (Utils .removeNonDigitCharacters (minutes ))) * 60 )
145+
146+ return ((Long .parseLong (Utils .removeNonDigitCharacters (days )) * 24
147+ + Long .parseLong (Utils .removeNonDigitCharacters (hours ))) * 60
148+ + Long .parseLong (Utils .removeNonDigitCharacters (minutes ))) * 60
148149 + Long .parseLong (Utils .removeNonDigitCharacters (seconds ));
149150 }
150151
Original file line number Diff line number Diff line change 55import org .schabi .newpipe .DownloaderTestImpl ;
66import org .schabi .newpipe .extractor .NewPipe ;
77import org .schabi .newpipe .extractor .exceptions .ExtractionException ;
8+ import org .schabi .newpipe .extractor .exceptions .ParsingException ;
89
910import java .io .IOException ;
1011
12+ import static org .junit .Assert .assertEquals ;
1113import static org .junit .Assert .assertTrue ;
1214
1315public class YoutubeParsingHelperTest {
@@ -27,4 +29,11 @@ public void testAreHardcodedYoutubeMusicKeysValid() throws IOException, Extracti
2729 assertTrue ("Hardcoded YouTube Music keys are not valid anymore" ,
2830 YoutubeParsingHelper .areHardcodedYoutubeMusicKeysValid ());
2931 }
32+
33+ @ Test
34+ public void testParseDurationString () throws ParsingException {
35+ assertEquals (1162567 , YoutubeParsingHelper .parseDurationString ("12:34:56:07" ));
36+ assertEquals (4445767 , YoutubeParsingHelper .parseDurationString ("1,234:56:07" ));
37+ assertEquals (754 , YoutubeParsingHelper .parseDurationString ("12:34 " ));
38+ }
3039}
You can’t perform that action at this time.
0 commit comments