<s> from __future__ import absolute_import <EOL> import re <EOL> import json <EOL> from svtplay_dl . service import Service <EOL> from svtplay_dl . utils import decode_html_entities <EOL> from svtplay_dl . error import ServiceError <EOL> from svtplay_dl . fetcher . hls import hlsparse <EOL> class Aftonbladet ( Service ) : <EOL> supported_domains = [ '<STR_LIT>' ] <EOL> def get ( self ) : <EOL> data = self . get_urldata ( ) <EOL> if self . exclude ( self . options ) : <EOL> yield ServiceError ( "<STR_LIT>" ) <EOL> return <EOL> match = re . search ( '<STR_LIT>' , data ) <EOL> if not match : <EOL> match = re . search ( '<STR_LIT>' , data ) <EOL> if not match : <EOL> yield ServiceError ( "<STR_LIT>" ) <EOL> return <EOL> janson = json . loads ( decode_html_entities ( match . group ( <NUM_LIT:1> ) ) ) <EOL> videoId = janson [ "<STR_LIT>" ] <EOL> else : <EOL> videoId = match . group ( <NUM_LIT:1> ) <EOL> match = re . search ( r'<STR_LIT>' , data ) <EOL> if not match : <EOL> yield ServiceError ( "<STR_LIT>" ) <EOL> return <EOL> if match . group ( <NUM_LIT:1> ) == "<STR_LIT:true>" : <EOL> self . options . live = True <EOL> if not self . options . live : <EOL> dataurl = "<STR_LIT>" % videoId <EOL> data = self . http . request ( "<STR_LIT>" , dataurl ) . text <EOL> data = json . loads ( data ) <EOL> videoId = data [ "<STR_LIT>" ] <EOL> streamsurl = "<STR_LIT>" % videoId <EOL> data = self . http . request ( "<STR_LIT>" , streamsurl ) . text <EOL> streams = json . loads ( data ) <EOL> hlsstreams = streams [ "<STR_LIT>" ] [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in hlsstreams . keys ( ) : <EOL> hls = hlsstreams [ "<STR_LIT>" ] <EOL> else : <EOL> hls = hlsstreams [ "<STR_LIT>" ] <EOL> if "<STR_LIT>" in hls . keys ( ) : <EOL> hls = hls [ "<STR_LIT>" ] [ <NUM_LIT:0> ] <EOL> else : <EOL> hls = hls [ "<STR_LIT>" ] [ <NUM_LIT:0> ] <EOL> address = hls [ "<STR_LIT:address>" ] <EOL> path = hls [ "<STR_LIT:path>" ] <EOL> for i in hls [ "<STR_LIT>" ] : <EOL> if "<STR_LIT:filename>" in i . keys ( ) : <EOL> plist = "<STR_LIT>" % ( address , path , i [ "<STR_LIT:filename>" ] ) <EOL> else : <EOL> plist = "<STR_LIT>" % ( address , path , hls [ "<STR_LIT:filename>" ] ) <EOL> streams = hlsparse ( self . options , self . http . request ( "<STR_LIT>" , plist ) , plist ) <EOL> if streams : <EOL> for n in list ( streams . keys ( ) ) : <EOL> yield streams [ n ] </s>
