<s> from __future__ import absolute_import <EOL> import re <EOL> import os <EOL> import json <EOL> import xml . etree . ElementTree as ET <EOL> from svtplay_dl . service import Service , OpenGraphThumbMixin <EOL> from svtplay_dl . utils import is_py2_old <EOL> from svtplay_dl . error import ServiceError <EOL> from svtplay_dl . log import log <EOL> from svtplay_dl . fetcher . rtmp import RTMP <EOL> from svtplay_dl . fetcher . hls import hlsparse <EOL> class Mtvnn ( Service , OpenGraphThumbMixin ) : <EOL> supported_domains = [ '<STR_LIT>' , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] <EOL> def get ( self ) : <EOL> data = self . get_urldata ( ) <EOL> match = re . search ( r'<STR_LIT>' , data ) <EOL> if not match : <EOL> yield ServiceError ( "<STR_LIT>" ) <EOL> return <EOL> data = self . http . request ( "<STR_LIT>" , match . group ( <NUM_LIT:1> ) ) . content <EOL> xml = ET . XML ( data ) <EOL> mediagen = xml . find ( "<STR_LIT>" ) . find ( "<STR_LIT>" ) . find ( "<STR_LIT>" ) <EOL> title = xml . find ( "<STR_LIT>" ) . find ( "<STR_LIT>" ) . find ( "<STR_LIT:title>" ) . text <EOL> if self . options . output_auto : <EOL> directory = os . path . dirname ( self . options . output ) <EOL> if len ( directory ) : <EOL> self . options . output = os . path . join ( directory , title ) <EOL> else : <EOL> self . options . output = title <EOL> if self . exclude ( self . options ) : <EOL> yield ServiceError ( "<STR_LIT>" ) <EOL> return <EOL> swfurl = mediagen . find ( "<STR_LIT>" ) . attrib [ "<STR_LIT:url>" ] <EOL> self . options . other = "<STR_LIT>" % self . http . check_redirect ( swfurl ) <EOL> contenturl = mediagen . find ( "<STR_LIT>" ) . attrib [ "<STR_LIT:url>" ] <EOL> filename = os . path . basename ( contenturl ) <EOL> data = self . http . request ( "<STR_LIT>" , "<STR_LIT>" % filename ) . text <EOL> dataj = json . loads ( data ) <EOL> content = self . http . request ( "<STR_LIT>" , contenturl ) . content <EOL> xml = ET . XML ( content ) <EOL> ss = xml . find ( "<STR_LIT>" ) . find ( "<STR_LIT>" ) <EOL> if is_py2_old : <EOL> sa = list ( ss . getiterator ( "<STR_LIT>" ) ) <EOL> else : <EOL> sa = list ( ss . iter ( "<STR_LIT>" ) ) <EOL> for i in sa : <EOL> yield RTMP ( self . options , i . find ( "<STR_LIT:src>" ) . text , i . attrib [ "<STR_LIT>" ] ) <EOL> streams = hlsparse ( self . options , self . http . request ( "<STR_LIT>" , dataj [ "<STR_LIT:src>" ] ) , dataj [ "<STR_LIT:src>" ] ) <EOL> if streams : <EOL> for n in list ( streams . keys ( ) ) : <EOL> yield streams [ n ] <EOL> def find_all_episodes ( self , options ) : <EOL> match = re . search ( r"<STR_LIT>" , self . get_urldata ( ) ) <EOL> if match is None : <EOL> log . error ( "<STR_LIT>" ) <EOL> return <EOL> programid = match . group ( <NUM_LIT:1> ) <EOL> match = re . findall ( r"<STR_LIT>" , self . get_urldata ( ) ) <EOL> if not match : <EOL> log . error ( "<STR_LIT>" ) <EOL> return <EOL> episodNr = [ ] <EOL> for i in match : <EOL> episodNr . append ( i [ <NUM_LIT:3> ] ) <EOL> episodes = [ ] <EOL> n = <NUM_LIT:0> <EOL> for i in sorted ( episodNr ) : <EOL> if n == options . all_last : <EOL> break <EOL> episodes . append ( "<STR_LIT>" % ( programid , i ) ) <EOL> n += <NUM_LIT:1> <EOL> return episodes </s>
