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

Audio convert #2

Merged
merged 21 commits into from
Aug 7, 2021
Prev Previous commit
Next Next commit
refactor
  • Loading branch information
automactic committed Jul 30, 2021
commit d7b13b29783ab4e88b51b830ee24ec5ab745d1d6
11 changes: 7 additions & 4 deletions app/recorders/tunein.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class Segment:


class TuneinStationRecorder:
DEFAULT_SLEEP_TIME = 120

def __init__(self, station_id: str, session: aiohttp.ClientSession):
self.station_id = station_id
self.session = session
Expand Down Expand Up @@ -109,12 +111,13 @@ async def _get_stream_url(self) -> Optional[str]:
return line
return None

@staticmethod
def _get_content_duration(lines: [str]) -> Optional[float]:
def _get_content_duration(self, lines: [str]) -> float:
"""Get available duration from response content of the stream url."""

for line in lines:
if line.startswith('#EXT-X-COM-TUNEIN-AVAIL-DUR:'):
try:
return float(line.replace('#EXT-X-COM-TUNEIN-AVAIL-DUR:', ''))
except ValueError:
return None
return None
break
return self.DEFAULT_SLEEP_TIME