#NEWLINE# def episodeDirectory( self , items ) : #NEWLINE# #INDENT# if ( ( items == None ) or ( len ( items ) == 0 ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# isFolder = ( True if ( ( control . setting ( 'autoplay' ) == 'false' ) and ( control . setting ( 'host_select' ) == '1' ) ) else False ) #NEWLINE# isFolder = ( False if ( control . window . getProperty ( 'PseudoTVRunning' ) == 'True' ) else isFolder ) #NEWLINE# playbackMenu = ( control . lang ( 30271 ) . encode ( 'utf-8' ) if ( control . setting ( 'autoplay' ) == 'true' ) else control . lang ( 30270 ) . encode ( 'utf-8' ) ) #NEWLINE# traktMode = ( False if ( trakt . getTraktCredentials ( ) == False ) else True ) #NEWLINE# cacheToDisc = False #NEWLINE# ( addonPoster , addonBanner ) = ( control . addonPoster ( ) , control . addonBanner ( ) ) #NEWLINE# ( addonFanart , settingFanart ) = ( control . addonFanart ( ) , control . setting ( 'fanart' ) ) #NEWLINE# sysaddon = sys . argv [ 0 ] #NEWLINE# try : #NEWLINE# #INDENT# multi = [ i [ 'tvshowtitle' ] for i in items ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# multi = [ ] #NEWLINE# #UNINDENT# multi = len ( [ x for ( y , x ) in enumerate ( multi ) if ( x not in multi [ : y ] ) ] ) #NEWLINE# multi = ( True if ( multi > 1 ) else False ) #NEWLINE# try : #NEWLINE# #INDENT# sysaction = items [ 0 ] [ 'action' ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# sysaction = '' #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# favitems = favourites . getFavourites ( 'tvshows' ) #NEWLINE# favitems = [ i [ 0 ] for i in favitems ] #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( traktMode == True ) : #NEWLINE# #INDENT# raise Exception ( ) #NEWLINE# #UNINDENT# from metahandler import metahandlers #NEWLINE# metaget = metahandlers . MetaData ( preparezip = False ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( traktMode == False ) : #NEWLINE# #INDENT# raise Exception ( ) #NEWLINE# #UNINDENT# indicators = trakt . syncTVShows ( timeout = 720 ) #NEWLINE# indicators = json . loads ( indicators ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# for i in items : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# if ( i [ 'title' ] == '0' ) : #NEWLINE# #INDENT# label = ( '%sx%02d . %s %s' % ( i [ 'season' ] , int ( i [ 'episode' ] ) , 'Episode' , i [ 'episode' ] ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# label = ( '%sx%02d . %s' % ( i [ 'season' ] , int ( i [ 'episode' ] ) , i [ 'title' ] ) ) #NEWLINE# #UNINDENT# if ( multi == True ) : #NEWLINE# #INDENT# label = ( '%s - %s' % ( i [ 'tvshowtitle' ] , label ) ) #NEWLINE# #UNINDENT# systitle = sysname = urllib . quote_plus ( i [ 'tvshowtitle' ] ) #NEWLINE# ( episodetitle , episodename ) = ( urllib . quote_plus ( i [ 'title' ] ) , urllib . quote_plus ( i [ 'name' ] ) ) #NEWLINE# syspremiered = urllib . quote_plus ( i [ 'premiered' ] ) #NEWLINE# ( imdb , tmdb , tvdb , tvrage , year , season , episode , alter ) = ( i [ 'imdb' ] , i [ 'tmdb' ] , i [ 'tvdb' ] , i [ 'tvrage' ] , i [ 'year' ] , i [ 'season' ] , i [ 'episode' ] , i [ 'alter' ] ) #NEWLINE# ( poster , banner , fanart , thumb ) = ( i [ 'poster' ] , i [ 'banner' ] , i [ 'fanart' ] , i [ 'thumb' ] ) #NEWLINE# if ( poster == '0' ) : #NEWLINE# #INDENT# poster = addonPoster #NEWLINE# #UNINDENT# if ( ( banner == '0' ) and ( poster == '0' ) ) : #NEWLINE# #INDENT# banner = addonBanner #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( banner == '0' ) : #NEWLINE# #INDENT# banner = poster #NEWLINE# #UNINDENT# #UNINDENT# if ( ( thumb == '0' ) and ( fanart == '0' ) ) : #NEWLINE# #INDENT# thumb = addonFanart #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( thumb == '0' ) : #NEWLINE# #INDENT# thumb = fanart #NEWLINE# #UNINDENT# #UNINDENT# meta = dict ( ( ( k , v ) for ( k , v ) in i . iteritems ( ) if ( not ( v == '0' ) ) ) ) #NEWLINE# meta . update ( { #NEWLINE# #INDENT# 'trailer' : ( '%s?action=trailer&name=%s' % ( sysaddon , sysname ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( i [ 'duration' ] == '0' ) : #NEWLINE# #INDENT# meta . update ( { #NEWLINE# #INDENT# 'duration' : '60' , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# meta . update ( { #NEWLINE# #INDENT# 'duration' : str ( ( int ( meta [ 'duration' ] ) * 60 ) ) , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# sysmeta = urllib . quote_plus ( json . dumps ( meta ) ) #NEWLINE# url = ( '%s?action=play&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s&t=%s' % ( sysaddon , episodename , episodetitle , year , imdb , tmdb , tvdb , tvrage , season , episode , systitle , alter , syspremiered , sysmeta , self . systime ) ) #NEWLINE# sysurl = urllib . quote_plus ( url ) #NEWLINE# if ( isFolder == True ) : #NEWLINE# #INDENT# url = ( '%s?action=sources&name=%s&title=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s&tvshowtitle=%s&alter=%s&date=%s&meta=%s' % ( sysaddon , episodename , episodetitle , year , imdb , tmdb , tvdb , tvrage , season , episode , systitle , alter , syspremiered , sysmeta ) ) #NEWLINE# #UNINDENT# if ( sysaction == 'episodes' ) : #NEWLINE# #INDENT# url = ( '%s?action=episodes&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s&season=%s&episode=%s' % ( sysaddon , systitle , year , imdb , tmdb , tvdb , tvrage , season , episode ) ) #NEWLINE# isFolder = True #NEWLINE# cacheToDisc = True #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( traktMode == True ) : #NEWLINE# #INDENT# raise Exception ( ) #NEWLINE# #UNINDENT# playcount = metaget . _get_watched_episode ( { #NEWLINE# #INDENT# 'imdb_id' : imdb , #NEWLINE# 'season' : season , #NEWLINE# 'episode' : episode , #NEWLINE# 'premiered' : '' , #NEWLINE# #UNINDENT# } ) #NEWLINE# if ( playcount == 7 ) : #NEWLINE# #INDENT# meta . update ( { #NEWLINE# #INDENT# 'playcount' : 1 , #NEWLINE# 'overlay' : 7 , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# meta . update ( { #NEWLINE# #INDENT# 'playcount' : 0 , #NEWLINE# 'overlay' : 6 , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( traktMode == False ) : #NEWLINE# #INDENT# raise Exception ( ) #NEWLINE# #UNINDENT# playcount = [ i for i in indicators if ( str ( i [ 'show' ] [ 'ids' ] [ 'tvdb' ] ) == tvdb ) ] [ 0 ] [ 'seasons' ] #NEWLINE# playcount = [ i for i in playcount if ( int ( i [ 'number' ] ) == int ( season ) ) ] [ 0 ] [ 'episodes' ] #NEWLINE# playcount = [ i for i in playcount if ( int ( i [ 'number' ] ) == int ( episode ) ) ] [ 0 ] #NEWLINE# meta . update ( { #NEWLINE# #INDENT# 'playcount' : 1 , #NEWLINE# 'overlay' : 7 , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# cm = [ ] #NEWLINE# cm . append ( ( playbackMenu , ( 'RunPlugin(%s?action=alterSources&url=%s&meta=%s)' % ( sysaddon , sysurl , sysmeta ) ) ) ) #NEWLINE# if ( isFolder == False ) : #NEWLINE# #INDENT# cm . append ( ( control . lang ( 30261 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=queueItem)' % sysaddon ) ) ) #NEWLINE# #UNINDENT# cm . append ( ( control . lang ( 30272 ) . encode ( 'utf-8' ) , 'Action(Info)' ) ) #NEWLINE# if ( multi == True ) : #NEWLINE# #INDENT# cm . append ( ( control . lang ( 30274 ) . encode ( 'utf-8' ) , ( 'ActivateWindow(Videos,%s?action=seasons&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s,return)' % ( sysaddon , systitle , year , imdb , tmdb , tvdb , tvrage ) ) ) ) #NEWLINE# #UNINDENT# cm . append ( ( control . lang ( 30263 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=7)' % ( sysaddon , imdb , tvdb , season , episode ) ) ) ) #NEWLINE# cm . append ( ( control . lang ( 30264 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=episodePlaycount&imdb=%s&tvdb=%s&season=%s&episode=%s&query=6)' % ( sysaddon , imdb , tvdb , season , episode ) ) ) ) #NEWLINE# if ( traktMode == True ) : #NEWLINE# #INDENT# cm . append ( ( control . lang ( 30265 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=traktManager&name=%s&tvdb=%s&content=tvshow)' % ( sysaddon , sysname , tvdb ) ) ) ) #NEWLINE# #UNINDENT# if ( ( not ( imdb in favitems ) ) and ( not ( tvdb in favitems ) ) ) : #NEWLINE# #INDENT# cm . append ( ( control . lang ( 30266 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=addFavourite&meta=%s&content=tvshows)' % ( sysaddon , sysmeta ) ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# cm . append ( ( control . lang ( 30267 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=deleteFavourite&meta=%s&content=tvshows)' % ( sysaddon , sysmeta ) ) ) ) #NEWLINE# #UNINDENT# cm . append ( ( control . lang ( 30268 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=tvshowToLibrary&tvshowtitle=%s&year=%s&imdb=%s&tmdb=%s&tvdb=%s&tvrage=%s)' % ( sysaddon , systitle , year , imdb , tmdb , tvdb , tvrage ) ) ) ) #NEWLINE# cm . append ( ( control . lang ( 30273 ) . encode ( 'utf-8' ) , ( 'RunPlugin(%s?action=addView&content=episodes)' % sysaddon ) ) ) #NEWLINE# item = control . item ( label = label , iconImage = thumb , thumbnailImage = thumb ) #NEWLINE# try : #NEWLINE# #INDENT# item . setArt ( { #NEWLINE# #INDENT# 'poster' : poster , #NEWLINE# 'tvshow.poster' : poster , #NEWLINE# 'season.poster' : poster , #NEWLINE# 'banner' : banner , #NEWLINE# 'tvshow.banner' : banner , #NEWLINE# 'season.banner' : banner , #NEWLINE# #UNINDENT# } ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# if ( ( settingFanart == 'true' ) and ( not ( fanart == '0' ) ) ) : #NEWLINE# #INDENT# item . setProperty ( 'Fanart_Image' , fanart ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( addonFanart == None ) ) : #NEWLINE# #INDENT# item . setProperty ( 'Fanart_Image' , addonFanart ) #NEWLINE# #UNINDENT# #UNINDENT# item . setInfo ( type = 'Video' , infoLabels = meta ) #NEWLINE# item . setProperty ( 'Video' , 'true' ) #NEWLINE# item . setProperty ( 'resumetime' , str ( 0 ) ) #NEWLINE# item . setProperty ( 'totaltime' , str ( 1 ) ) #NEWLINE# item . addContextMenuItems ( cm , replaceItems = True ) #NEWLINE# control . addItem ( handle = int ( sys . argv [ 1 ] ) , url = url , listitem = item , isFolder = banner ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# control . content ( int ( sys . argv [ 1 ] ) , 'episodes' ) #NEWLINE# control . directory ( int ( sys . argv [ 1 ] ) , cacheToDisc = cacheToDisc ) #NEWLINE# views . setView ( 'episodes' , { #NEWLINE# #INDENT# 'skin.confluence' : 504 , #NEWLINE# #UNINDENT# } )