r'#(?!EXT)', # comment
}
- time_str = resp.info().get('Date')
- time = None
- if time_str:
- try:
- time = datetime.datetime.strptime(time_str, '%a, %d %b %Y %H:%M:%S %Z')
- except ValueError:
- pass
- else:
- time = time.replace(tzinfo = datetime.timezone.utc)
-
def gen_parsed(lines):
lines = iter(lines)
while True:
body = resp.read().decode('utf-8')
parsed = list(gen_parsed(body.splitlines()))
- playlist = Playlist.from_entries(parsed)
- return Capture(time, playlist)
+ return Playlist.from_entries(parsed)
def _unparse(entry):
if isinstance(entry, Segment):
+import datetime
+
from hls_watch import *
_DELAY = datetime.timedelta(seconds = 10)
+def get_time(resp):
+ time_str = resp.info().get('Date')
+ time = None
+ if time_str:
+ print(time_str)
+ try:
+ time = datetime.datetime.strptime(time_str, '%a, %d %b %Y %H:%M:%S %Z')
+ except ValueError:
+ pass
+ else:
+ return time.replace(tzinfo = datetime.timezone.utc)
+ return None
+
+
if __name__ == '__main__':
import argparse
import contextlib
handler.on_404()
else:
assert resp.status == 200
- handler.update(parse(resp))
+ handler.update(Capture(
+ time = get_time(resp),
+ playlist = parse(resp),
+ ))
time.sleep(_DELAY.total_seconds())