Skip to content

Commit 15d9368

Browse files
committed
fix(youtube): correctly parse publish time of past live videos
1 parent 054e54d commit 15d9368

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

background/util.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,15 @@ util.ajax.next = function() {
123123
* @return {Number}
124124
*/
125125
util.relativeToTimestamp = function(str) {
126-
var s = str.trim().split(' ');
127-
var n = parseInt(s[0], 10);
126+
var r = /(\d+)\s+(second|minute|hour|day)s?/.exec(str);
127+
if (!r) { return null; }
128+
var n = parseInt(r[1], 10);
128129
var multiplier = {
129130
second: 1,
130-
seconds: 1,
131131
minute: 60,
132-
minutes: 60,
133132
hour: 3600,
134-
hours: 3600,
135133
day: 86400,
136-
days: 86400,
137-
}[s[1]];
134+
}[r[2]];
138135
return Date.now() - n * multiplier * 1000;
139136
};
140137

0 commit comments

Comments
 (0)