<s> import urllib , urllib2 , re , os , sys , math <EOL> import xbmcgui , xbmc , xbmcaddon , xbmcplugin <EOL> from urlparse import urlparse , parse_qs <EOL> import urlparse , httplib <EOL> import mrknow_pLog , mrknow_pCommon , mrknow_Parser , mrknow_Player , mrknow_urlparser <EOL> try : <EOL> import simplejson as json <EOL> except ImportError : <EOL> import json <EOL> scriptID = '<STR_LIT>' <EOL> scriptname = "<STR_LIT>" <EOL> ptv = xbmcaddon . Addon ( scriptID ) <EOL> BASE_RESOURCE_PATH = os . path . join ( ptv . getAddonInfo ( '<STR_LIT:path>' ) , "<STR_LIT>" ) <EOL> sys . path . append ( os . path . join ( BASE_RESOURCE_PATH , "<STR_LIT>" ) ) <EOL> log = mrknow_pLog . pLog ( ) <EOL> catUrl = '<STR_LIT>' <EOL> imgurl = '<STR_LIT>' <EOL> mainUrl = '<STR_LIT>' <EOL> playerUrl = '<STR_LIT>' <EOL> HOST = '<STR_LIT>' <EOL> null = <NUM_LIT:0> <EOL> true = <NUM_LIT:1> <EOL> false = <NUM_LIT:0> <EOL> MENU_TAB = { <NUM_LIT:2> : "<STR_LIT>" , <EOL> <NUM_LIT:3> : "<STR_LIT>" , <EOL> <NUM_LIT:4> : "<STR_LIT>" , <EOL> } <EOL> class strefavod : <EOL> def __init__ ( self ) : <EOL> log . info ( '<STR_LIT>' ) <EOL> self . cm = mrknow_pCommon . common ( ) <EOL> self . parser = mrknow_Parser . mrknow_Parser ( ) <EOL> self . up = mrknow_urlparser . mrknow_urlparser ( ) <EOL> self . p = mrknow_Player . mrknow_Player ( ) <EOL> def getpage ( self , url , data = None ) : <EOL> print ( "<STR_LIT>" , url ) <EOL> header = { "<STR_LIT>" : "<STR_LIT>" , "<STR_LIT>" : "<STR_LIT:1.0>" , "<STR_LIT>" : "<STR_LIT>" } <EOL> req = urllib2 . Request ( url , data , header ) <EOL> f = urllib2 . urlopen ( req ) <EOL> response = f . read ( ) <EOL> f . close ( ) <EOL> print ( "<STR_LIT>" , response ) <EOL> return response <EOL> def listsMainMenu ( self , table ) : <EOL> for num , val in table . items ( ) : <EOL> self . add ( '<STR_LIT>' , '<STR_LIT>' , val , val , '<STR_LIT:None>' , '<STR_LIT:None>' , '<STR_LIT:None>' , '<STR_LIT:None>' , True , False ) <EOL> xbmcplugin . endOfDirectory ( int ( sys . argv [ <NUM_LIT:1> ] ) ) <EOL> def listsCategoriesMenu ( self , url ) : <EOL> valTab = [ ] <EOL> strTab = [ ] <EOL> vod_filmy = eval ( self . getpage ( url , None ) ) <EOL> print ( "<STR_LIT>" , vod_filmy ) <EOL> for e in vod_filmy [ "<STR_LIT>" ] : <EOL> print ( "<STR_LIT:E>" , e ) <EOL> strTab . append ( self . cm . html_special_chars ( e [ "<STR_LIT:Name>" ] ) ) <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> valTab . append ( strTab ) <EOL> strTab = [ ] <EOL> valTab . sort ( key = lambda x : x [ <NUM_LIT:0> ] ) <EOL> for i in valTab : <EOL> self . add ( '<STR_LIT>' , '<STR_LIT>' , i [ <NUM_LIT:3> ] , i [ <NUM_LIT:0> ] + '<STR_LIT>' + str ( i [ <NUM_LIT:1> ] ) + '<STR_LIT:)>' , '<STR_LIT:None>' , '<STR_LIT:None>' , '<STR_LIT:None>' , '<STR_LIT:None>' , True , False , str ( i [ <NUM_LIT:2> ] ) ) <EOL> xbmcplugin . endOfDirectory ( int ( sys . argv [ <NUM_LIT:1> ] ) ) <EOL> def listsItems ( self , id1 , url = '<STR_LIT>' ) : <EOL> valTab = [ ] <EOL> strTab = [ ] <EOL> if url == '<STR_LIT>' : <EOL> url = '<STR_LIT>' + id1 + '<STR_LIT>' <EOL> vod_items = eval ( self . getpage ( url , None ) ) <EOL> print ( "<STR_LIT>" , vod_items ) <EOL> for e in vod_items [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> strTab . append ( e [ "<STR_LIT>" ] ) <EOL> valTab . append ( strTab ) <EOL> strTab = [ ] <EOL> valTab . sort ( key = lambda x : x [ <NUM_LIT:0> ] ) <EOL> for i in valTab : <EOL> self . add ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:None>' , i [ <NUM_LIT:0> ] , i [ <NUM_LIT:1> ] , '<STR_LIT:None>' , '<STR_LIT:None>' , '<STR_LIT:None>' , False , False , str ( i [ <NUM_LIT:2> ] ) ) <EOL> xbmcplugin . endOfDirectory ( int ( sys . argv [ <NUM_LIT:1> ] ) ) <EOL> def getMovieLinkFromXML ( self , id1 ) : <EOL> url = '<STR_LIT>' + id1 <EOL> vod_items = eval ( self . getpage ( url , None ) ) <EOL> for e in vod_items [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] : <EOL> if e [ "<STR_LIT>" ] == "<STR_LIT>" : <EOL> print "<STR_LIT>" <EOL> if len ( e [ "<STR_LIT>" ] ) > <NUM_LIT:0> : <EOL> url = e [ "<STR_LIT>" ] [ <NUM_LIT:0> ] [ "<STR_LIT>" ] <EOL> print ( "<STR_LIT:u>" , url ) <EOL> if len ( url ) > <NUM_LIT:0> : <EOL> return url <EOL> else : <EOL> return '<STR_LIT>' <EOL> def getMovieYear ( self , id1 ) : <EOL> url = '<STR_LIT>' + id1 <EOL> vod_items = eval ( self . getpage ( url , None ) ) <EOL> print ( "<STR_LIT>" , vod_items [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> if len ( str ( vod_items [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) ) > <NUM_LIT:0> : <EOL> return str ( vod_items [ "<STR_LIT>" ] [ "<STR_LIT>" ] [ "<STR_LIT>" ] ) <EOL> def getSearchURL ( self ) : <EOL> text = self . searchInputText ( ) <EOL> url = '<STR_LIT>' + urllib . quote_plus ( text ) <EOL> self . listsItems ( '<STR_LIT>' , url ) <EOL> def searchInputText ( self ) : <EOL> text = None <EOL> k = xbmc . Keyboard ( ) <EOL> k . doModal ( ) <EOL> if ( k . isConfirmed ( ) ) : <EOL> text = k . getText ( ) <EOL> return text <EOL> def add ( self , service , name , category , title , iconimage , url , desc , rating , folder = True , isPlayable = True , id1 = '<STR_LIT:0>' , id2 = '<STR_LIT:0>' , year = '<STR_LIT>' ) : <EOL> u = sys . argv [ <NUM_LIT:0> ] + "<STR_LIT>" + service + "<STR_LIT>" + name + "<STR_LIT>" + category + "<STR_LIT>" + title + "<STR_LIT>" + urllib . quote_plus ( url ) + "<STR_LIT>" + urllib . quote_plus ( iconimage ) + "<STR_LIT>" + urllib . quote_plus ( id1 ) + "<STR_LIT>" + urllib . quote_plus ( id2 ) + "<STR_LIT>" + urllib . quote_plus ( year ) <EOL> if iconimage == '<STR_LIT>' : <EOL> iconimage = "<STR_LIT>" <EOL> liz = xbmcgui . ListItem ( title , iconImage = "<STR_LIT>" , thumbnailImage = iconimage ) <EOL> if isPlayable : <EOL> liz . setProperty ( "<STR_LIT>" , "<STR_LIT:true>" ) <EOL> liz . setInfo ( type = "<STR_LIT>" , infoLabels = { "<STR_LIT>" : title } ) <EOL> xbmcplugin . addDirectoryItem ( handle = int ( sys . argv [ <NUM_LIT:1> ] ) , url = u , listitem = liz , isFolder = folder ) <EOL> def handleService ( self ) : <EOL> params = self . parser . getParams ( ) <EOL> name = self . parser . getParam ( params , "<STR_LIT:name>" ) <EOL> category = self . parser . getParam ( params , "<STR_LIT>" ) <EOL> url = self . parser . getParam ( params , "<STR_LIT:url>" ) <EOL> title = self . parser . getParam ( params , "<STR_LIT:title>" ) <EOL> icon = self . parser . getParam ( params , "<STR_LIT>" ) <EOL> id1 = self . parser . getParam ( params , "<STR_LIT>" ) <EOL> id2 = self . parser . getParam ( params , "<STR_LIT>" ) <EOL> year = self . parser . getParam ( params , "<STR_LIT>" ) <EOL> print ( "<STR_LIT>" , category , id1 , id2 , icon , year ) <EOL> if name == None : <EOL> self . listsMainMenu ( MENU_TAB ) <EOL> elif name == '<STR_LIT>' and category == '<STR_LIT>' : <EOL> log . info ( '<STR_LIT>' ) <EOL> self . listsCategoriesMenu ( '<STR_LIT>' ) <EOL> elif name == '<STR_LIT>' and category == '<STR_LIT>' : <EOL> log . info ( '<STR_LIT>' ) <EOL> self . listsItems ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> elif name == '<STR_LIT>' and category == '<STR_LIT>' : <EOL> log . info ( '<STR_LIT>' ) <EOL> self . getSearchURL ( ) <EOL> elif name == '<STR_LIT>' and id1 != '<STR_LIT>' : <EOL> log . info ( '<STR_LIT>' ) <EOL> self . listsItems ( id1 ) <EOL> if name == '<STR_LIT>' : <EOL> self . p . LOAD_AND_PLAY_VIDEO ( self . getMovieLinkFromXML ( id1 ) , title , icon , self . getMovieYear ( id1 ) ) <EOL> if name == '<STR_LIT>' : <EOL> self . p . LOAD_AND_PLAY_VIDEO ( self . getMovieLinkFromXML ( id1 ) , title , icon , self . getMovieYear ( id1 ) ) </s>
