Skip to content

Commit 37b181b

Browse files
committed
Overcast 3 changes the way lengths are reported in the frontend.
1 parent a25e8c3 commit 37b181b

File tree

1 file changed

+25
-8
lines changed

1 file changed

+25
-8
lines changed

utilities.py

+25-8
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,35 @@
99

1010
log = logging.getLogger('overcast-sonos')
1111

12+
# We used to look for a 'hh:mm:ss' string and then parse that to seconds, but now overcast only returns minutes :(
13+
# def duration_in_seconds(str):
14+
# seconds = -1
15+
# try:
16+
# strings = str.split(' ')
17+
# for string in strings:
18+
# if ":" in string:
19+
# list = string.split(":")
20+
# list.reverse()
21+
# for i, x in enumerate(list):
22+
# seconds += int(x) * (60**i)
23+
# break
24+
# except:
25+
# log.debug('''Couldn't parse the episode's duration in seconds from the string %s.''', str)
26+
# pass
27+
#
28+
# log.debug('''Parsed the episode's duration in seconds from the string %s -> %d''', str, seconds)
29+
#
30+
# return seconds
31+
32+
# turns a string like 'Feb 24 - 36 min left' into seconds
33+
1234

1335
def duration_in_seconds(str):
1436
seconds = -1
1537
try:
16-
strings = str.split(' ')
17-
for string in strings:
18-
if ":" in string:
19-
list = string.split(":")
20-
list.reverse()
21-
for i, x in enumerate(list):
22-
seconds += int(x) * (60**i)
23-
break
38+
strings = str.split()
39+
minuteIndex = strings.index('min') - 1
40+
seconds = int(strings[minuteIndex]) * 60
2441
except:
2542
log.debug('''Couldn't parse the episode's duration in seconds from the string %s.''', str)
2643
pass

0 commit comments

Comments
 (0)