Ignore:
Timestamp:
Aug 19, 2011, 9:48:11 AM (15 years ago)
Author:
bonkel
Message:

fix swapmytube

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ipk/source.sh4/swapplayers_mytube_1_0/var/swap/extensions/MyTube/plugin.py

    r7451 r8953  
    1 from __init__ import _
    21from Plugins.Plugin import PluginDescriptor
    3 from MyTubeService import GoogleSuggestions
     2from MyTubeService import GoogleSuggestions, validate_cert, get_rnd
    43from MyTubeSearch import ConfigTextWithGoogleSuggestions
    54from Tools.BoundFunction import boundFunction
     
    3029from threading import Condition
    3130
    32 from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_HDD
     31from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_HDD, SCOPE_CURRENT_PLUGIN
    3332from Tools.LoadPixmap import LoadPixmap
    3433from Tools.Downloader import HTTPProgressDownloader, downloadWithProgress
     
    4039
    4140from Screens.InfoBarGenerics import InfoBarShowHide, InfoBarSeek, InfoBarNotifications, InfoBarServiceNotifications
     41from __init__ import bin2long, long2bin, rsa_pub1024, decrypt_block
     42
     43
     44
     45class eTPM:
     46                TPMD_DT_LEVEL3_CERT = 5
     47                TPMD_DT_LEVEL2_CERT = 4
     48                def __init__(self):
     49                        self.TPM = self
     50                def getCert(self, *args):
     51                        return "12345678"
     52                def challenge(self, r):
     53                        return r
     54def decrypt_block(a,b):
     55                return 80*"-" + a
     56def get_rnd():
     57                return "12345678"
     58def validate_cert(*args):
     59                return "12345678"
     60
     61etpm = eTPM()
     62rootkey = ['\x9f', '|', '\xe4', 'G', '\xc9', '\xb4', '\xf4', '#', '&', '\xce', '\xb3', '\xfe', '\xda', '\xc9', 'U', '`', '\xd8', '\x8c', 's', 'o', '\x90', '\x9b', '\\', 'b', '\xc0', '\x89', '\xd1', '\x8c', '\x9e', 'J', 'T', '\xc5', 'X', '\xa1', '\xb8', '\x13', '5', 'E', '\x02', '\xc9', '\xb2', '\xe6', 't', '\x89', '\xde', '\xcd', '\x9d', '\x11', '\xdd', '\xc7', '\xf4', '\xe4', '\xe4', '\xbc', '\xdb', '\x9c', '\xea', '}', '\xad', '\xda', 't', 'r', '\x9b', '\xdc', '\xbc', '\x18', '3', '\xe7', '\xaf', '|', '\xae', '\x0c', '\xe3', '\xb5', '\x84', '\x8d', '\r', '\x8d', '\x9d', '2', '\xd0', '\xce', '\xd5', 'q', '\t', '\x84', 'c', '\xa8', ')', '\x99', '\xdc', '<', '"', 'x', '\xe8', '\x87', '\x8f', '\x02', ';', 'S', 'm', '\xd5', '\xf0', '\xa3', '_', '\xb7', 'T', '\t', '\xde', '\xa7', '\xf1', '\xc9', '\xae', '\x8a', '\xd7', '\xd2', '\xcf', '\xb2', '.', '\x13', '\xfb', '\xac', 'j', '\xdf', '\xb1', '\x1d', ':', '?']
    4263
    4364config.plugins.mytube = ConfigSubsection()
     
    124145                                [
    125146                                 ("hd", _("HD videos")),
    126                                  ("most_viewed", _("Most viewed")),
     147#                                ("most_viewed", _("Most viewed")),
    127148                                 ("top_rated", _("Top rated")),
    128149                                 ("recently_featured", _("Recently featured")),
     
    132153                                 ("most_responded", _("Most responded")),
    133154                                 ("most_recent", _("Most recent"))
    134                                 ], "most_viewed")
     155                                ], "top_rated")
    135156config.plugins.mytube.general.on_movie_stop = ConfigSelection(default = "ask", choices = [
    136157        ("ask", _("Ask user")), ("quit", _("Return to movie list")), ("playnext", _("Play next video")), ("playagain", _("Play video again")) ])
     
    193214class MyTubePlayerMainScreen(Screen, ConfigListScreen):
    194215        BASE_STD_FEEDURL = "http://gdata.youtube.com/feeds/api/standardfeeds/"
     216        Details = {}
    195217        #(entry, Title, Description, TubeID, thumbnail, PublishedDate,Views,duration,ratings ) 
    196218        skin = """
    197                 <screen name="MyTubePlayerMainScreen" position="center,center" size="720,576" title="MyTubePlayerMainScreen..." >
    198                 <eLabel backgroundColor="#32000000" position="0,0" size="720,576" zPosition="-1"/>             
    199                 <widget name="config" zPosition="2" position="60,60" size="600,50" scrollbarMode="showNever" transparent="1" />
    200                         <widget source="feedlist" render="Listbox" position="49,110" size="628,385" zPosition="1" scrollbarMode="showOnDemand" transparent="1" >
     219                <screen name="MyTubePlayerMainScreen" flags="wfNoBorder" position="0,0" size="720,576" title="MyTubePlayerMainScreen..." >
     220                        <ePixmap position="0,0" zPosition="-1" size="720,576" pixmap="~/mytubemain_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
     221                        <widget name="config" zPosition="2" position="60,60" size="600,50" scrollbarMode="showNever" transparent="1" />
     222                        <widget source="feedlist" render="Listbox" position="49,110" size="628,385" zPosition="1" scrollbarMode="showOnDemand" transparent="1" backgroundPixmap="~/list_bg.png" selectionPixmap="~/list_sel.png" >
    201223                                <convert type="TemplatedMultiContent">
    202224                                {"templates":
     
    223245                        <ePixmap pixmap="skin_default/buttons/key_menu.png" position="50,520" zPosition="4" size="35,25" alphatest="on" transparent="1" />
    224246                        <ePixmap position="90,500" size="100,40" zPosition="4" pixmap="~/plugin.png" alphatest="on" transparent="1" />
    225                         <eLabel backgroundColor="red" position="190,500" size="140,3" zPosition="4"/>
    226                         <eLabel backgroundColor="green" position="330,500" size="140,3" zPosition="4"/>
    227                         <eLabel backgroundColor="yellow" position="470,500" size="140,3" zPosition="2"/>
     247                        <ePixmap position="190,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
     248                        <ePixmap position="330,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
     249                        <ePixmap position="470,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
    228250                        <widget name="key_red" position="190,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
    229251                        <widget name="key_green" position="330,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
     
    235257                </screen>"""
    236258               
    237         def __init__(self, session):
     259        def __init__(self, session, l2key):
    238260                Screen.__init__(self, session)
    239261                self.session = session
     262                self.l2key = l2key
     263                self.l3key = None
    240264                self.skin_path = plugin_path
    241265                self.FeedURL = None
     
    243267                self.currentFeedName = None
    244268                self.videolist = []
    245                 self.thumbnails = []
     269
    246270                self.video_playlist = []
    247271                self.statuslist = []
    248272                self.mytubeentries = None
     273
     274                self.thumbnails = []
    249275                self.index = 0
    250276                self.maxentries = 0
     277
     278                self.screenshotList = []
     279                self.pixmaps_to_load = []
    251280                self.picloads = {}
     281
    252282                self.oldfeedentrycount = 0
    253283                self.appendEntries = False
     
    261291                self.currList = "configlist"
    262292                self.oldlist = None
    263                 self.CleanupConsole = None
     293
    264294                self["feedlist"] = List(self.videolist)
    265295                self["thumbnail"] = Pixmap()
     
    345375                self["statusactions"].setEnabled(False)
    346376                self["historyactions"].setEnabled(False)
    347                 self.timer = eTimer()
    348                 self.timer.callback.append(self.picloadTimeout)
     377               
     378                self.timer_startDownload = eTimer()
     379                self.timer_startDownload.timeout.callback.append(self.downloadThumbnails)
     380                self.timer_thumbnails = eTimer()
     381                self.timer_thumbnails.timeout.callback.append(self.updateFeedThumbnails)
     382
    349383                self.SearchConfigEntry = None
    350384                self.searchContextEntries = []
     
    360394        def __onClose(self):
    361395                del self.Timer
    362                 del self.timer
     396                del self.timer_startDownload
     397                del self.timer_thumbnails
     398                self.Details = {}
    363399                self.session.nav.playService(self.lastservice)
    364400               
    365401        def layoutFinished(self):
    366402                self.currList = "status"
    367                 #self["key_green"].hide()
    368403                current = self["config"].getCurrent()
    369404                if current[1].help_window.instance is not None:
    370405                        current[1].help_window.instance.hide()
    371                 self.statuslist.append(( _("Fetching feed entries"), _("Trying to download the Youtube feed entries. Please wait..." ) ))
    372                 self["feedlist"].style = "state"
    373                 self['feedlist'].setList(self.statuslist)
    374                 self.Timer.start(200)
    375 
     406
     407                l3cert = etpm.getCert(eTPM.TPMD_DT_LEVEL3_CERT)
     408                if l3cert is None or l3cert is "":
     409                        self["videoactions"].setEnabled(False)
     410                        self["searchactions"].setEnabled(False)
     411                        self["config_actions"].setEnabled(False)
     412                        self["historyactions"].setEnabled(False)
     413                        self["statusactions"].setEnabled(True)
     414                        self.hideSuggestions()
     415                        self.statuslist = []
     416                        self.statuslist.append(( _("Genuine Dreambox validation failed!"), _("Verify your Dreambox authenticity by running the genuine dreambox plugin!" ) ))
     417                        self["feedlist"].style = "state"
     418                        self['feedlist'].setList(self.statuslist)
     419                        return
     420
     421                self.l3key = validate_cert(l3cert, self.l2key)
     422                if self.l3key is None:
     423                        print "l3cert invalid"
     424                        return
     425                rnd = get_rnd()
     426                if rnd is None:
     427                        print "random error"
     428                        return
     429
     430                val = etpm.challenge(rnd)
     431                result = decrypt_block(val, self.l3key)
     432
     433                self.statuslist = []
     434                if result[80:88] == rnd:
     435                        self.statuslist.append(( _("Fetching feed entries"), _("Trying to download the Youtube feed entries. Please wait..." ) ))
     436                        self["feedlist"].style = "state"
     437                        self['feedlist'].setList(self.statuslist)
     438                        self.Timer.start(200)
     439                else:
     440                        self.statuslist.append(( _("Genuine Dreambox validation failed!"), _("Verify your Dreambox authenticity by running the genuine dreambox plugin!" ) ))
     441                        self["feedlist"].style = "state"
     442                        self['feedlist'].setList(self.statuslist)               
     443       
    376444        def TimerFire(self):
    377445                self.Timer.stop()
     
    393461        def setState(self,status = None):
    394462                if status:
    395                         if self.FirstRun == True:
    396                                 self.appendEntries = False
    397                                 myTubeService.startService()
    398463                        self.currList = "status"
    399                         self.statuslist = []
    400464                        self["videoactions"].setEnabled(False)
    401465                        self["searchactions"].setEnabled(False)
    402                         #self["key_green"].hide()
    403466                        self["config_actions"].setEnabled(False)
    404467                        self["historyactions"].setEnabled(False)
     
    406469                        self["ButtonBlue"].hide()
    407470                        self["VKeyIcon"].hide()
    408                         if self.HistoryWindow is not None:
    409                                 self.HistoryWindow.deactivate()
    410                                 self.HistoryWindow.instance.hide()
    411                         if status == 'getFeed':
    412                                 self.hideSuggestions()
    413                                 self.statuslist.append(( _("Fetching feed entries"), _("Trying to download the Youtube feed entries. Please wait..." ) ))
     471                        self.statuslist = []
     472                        self.hideSuggestions()
     473                        result = None
     474                        if self.l3key is not None:
     475                                rnd = get_rnd()
     476                                if rnd is None:
     477                                        return
     478                                val = etpm.challenge(rnd)
     479                                result = decrypt_block(val, self.l3key)
     480                        if not result or result[80:88] != rnd:
     481                                self["key_green"].show()
     482                                self.statuslist.append(( _("Genuine Dreambox validation failed!"), _("Verify your Dreambox authenticity by running the genuine dreambox plugin!" ) ))
    414483                                self["feedlist"].style = "state"
    415484                                self['feedlist'].setList(self.statuslist)
    416                         elif status == 'getSearchFeed':
    417                                 self.hideSuggestions()
    418                                 self.statuslist.append(( _("Fetching search entries"), _("Trying to download the Youtube search results. Please wait..." ) ))
     485                        else:
     486                                print "Genuine Dreambox validation passed"
     487                                if self.FirstRun == True:
     488                                        self.appendEntries = False
     489                                        myTubeService.startService()
     490                                if self.HistoryWindow is not None:
     491                                        self.HistoryWindow.deactivate()
     492                                        self.HistoryWindow.instance.hide()
     493                                if status == 'getFeed':
     494                                        self.statuslist.append(( _("Fetching feed entries"), _("Trying to download the Youtube feed entries. Please wait..." ) ))
     495                                elif status == 'getSearchFeed':
     496                                        self.statuslist.append(( _("Fetching search entries"), _("Trying to download the Youtube search results. Please wait..." ) ))
     497                                elif status == 'Error':
     498                                        self.statuslist.append(( _("An error occured."), _("There was an error getting the feed entries. Please try again." ) ))
     499                                elif status == 'noVideos':
     500                                        self["key_green"].show()
     501                                        self.statuslist.append(( _("No videos to display"), _("Please select a standard feed or try searching for videos." ) ))
     502                                elif status == 'byPass':
     503                                        self.statuslist.append(( _("Not fetching feed entries"), _("Please enter your search term." ) ))
     504                                        self["feedlist"].style = "state"
     505                                        self['feedlist'].setList(self.statuslist)
     506                                        self.switchToConfigList()
    419507                                self["feedlist"].style = "state"
    420508                                self['feedlist'].setList(self.statuslist)
    421                         elif status == 'Error':
    422                                 self.hideSuggestions()
    423                                 self.statuslist.append(( _("An error occured."), _("There was an error getting the feed entries. Please try again." ) ))
    424                                 self["feedlist"].style = "state"
    425                                 self['feedlist'].setList(self.statuslist)
    426                         elif status == 'noVideos':
    427                                 self["key_green"].show()
    428                                 self.hideSuggestions()
    429                                 self.statuslist.append(( _("No videos to display"), _("Please select a standard feed or try searching for videos." ) ))
    430                                 self["feedlist"].style = "state"
    431                                 self['feedlist'].setList(self.statuslist)
    432                         elif status == 'byPass':
    433                                 self.statuslist.append(( _("Not fetching feed entries"), _("Please enter your search term." ) ))
    434                                 self["feedlist"].style = "state"
    435                                 self['feedlist'].setList(self.statuslist)
    436                                 self.switchToConfigList()
    437                         if self.FirstRun == True:
    438                                 if config.plugins.mytube.general.loadFeedOnOpen.value:
    439                                         if config.plugins.mytube.general.startFeed.value == 'hd':
    440                                                 self.FeedURL = "http://gdata.youtube.com/feeds/api/videos/-/HD"
    441                                         else:
    442                                                 self.FeedURL = self.BASE_STD_FEEDURL + str(config.plugins.mytube.general.startFeed.value)
    443                                         self.getFeed(self.FeedURL, str(config.plugins.mytube.general.startFeed.value))
     509                                if self.FirstRun == True:
     510                                        if config.plugins.mytube.general.loadFeedOnOpen.value:
     511                                                if config.plugins.mytube.general.startFeed.value == 'hd':
     512                                                        self.FeedURL = "http://gdata.youtube.com/feeds/api/videos/-/HD"
     513                                                else:
     514                                                        self.FeedURL = self.BASE_STD_FEEDURL + str(config.plugins.mytube.general.startFeed.value)
     515                                                self.getFeed(self.FeedURL, str(config.plugins.mytube.general.startFeed.value))
    444516
    445517
     
    467539
    468540        def handleMenu(self):
    469                 print "currlist im HandleMenu:",self.currList
    470541                if self.currList == "configlist":
    471542                        menulist = (
     
    492563        def openMenu(self, answer):
    493564                answer = answer and answer[1]
    494                 print "openMenu - ANSWER",answer
    495565                if answer == "settings":
    496566                        print "settings selected"
     
    519589                        self.session.open(MyTubeTasksScreen, self.skin_path , self.tasklist)           
    520590                elif answer == None:
    521                         print "No menuentry selected, we should just switch back to old state."
    522591                        self.ScreenClosed()
    523592       
     
    530599                if self.currList == "historylist":
    531600                        if self.HistoryWindow.status() is False:
    532                                 print "status is FALSE"
    533601                                self.HistoryWindow.activate()
    534602                                self.HistoryWindow.instance.show()
     
    553621        def openStandardFeedClosed(self, answer):
    554622                answer = answer and answer[1]
    555                 print "openStandardFeedClosed - ANSWER",answer
    556623                if answer is not None:
    557624                        if answer == 'hd':
     
    583650
    584651        def leavePlayer(self):
    585                 print "self.currList im leavePlayer",self.currList
     652                print "leavePlayer"
    586653                if self.HistoryWindow is not None:
    587654                        self.HistoryWindow.deactivate()
     
    602669        def leavePlayerConfirmed(self, answer):
    603670                answer = answer and answer[1]
    604                 print "ANSWER",answer
    605671                if answer == "quit":
    606                         cmd = "rm -rf /tmp/*.jpg"
    607                         self.CleanupConsole = Console()
    608                         self.CleanupConsole.ePopen(cmd, self.doQuit)
     672                        self.doQuit()
    609673                elif answer == "continue":
    610674                        if self.currList == "historylist":
    611675                                if self.HistoryWindow.status() is False:
    612                                         print "status is FALSE"
    613676                                        self.HistoryWindow.activate()
    614677                                        self.HistoryWindow.instance.show()
     
    622685                        self.switchToConfigList()
    623686                elif answer == None:
    624                         print "No menuentry selected, we should just switch back to old state."
    625687                        if self.currList == "historylist":
    626688                                if self.HistoryWindow.status() is False:
    627                                         print "status is FALSE"
    628689                                        self.HistoryWindow.activate()
    629690                                        self.HistoryWindow.instance.show()
     
    633694                                self.switchToFeedList()
    634695
    635         def doQuit(self, result, retval,extra_args):
     696        def doQuit(self):
    636697                if self["config"].getCurrent()[1].suggestionsWindow is not None:
    637698                        self.session.deleteDialog(self["config"].getCurrent()[1].suggestionsWindow)
     
    641702                        config.plugins.mytube.general.showHelpOnOpen.value = False
    642703                        config.plugins.mytube.general.showHelpOnOpen.save()
    643                 print "self.History im doQuit:",self.History
    644704                if not config.plugins.mytube.general.clearHistoryOnClose.value:
    645705                        if self.History and len(self.History):
     
    650710                config.plugins.mytube.general.save()
    651711                config.plugins.mytube.save()
    652                 if self.CleanupConsole is not None:
    653                         if len(self.CleanupConsole.appContainers):
    654                                 for name in self.CleanupConsole.appContainers.keys():
    655                                         self.CleanupConsole.kill(name)
    656712                self.close()
    657713                       
    658714        def keyOK(self):
    659                 print "self.currList----->",self.currList
     715                print "self.currList im KeyOK",self.currList
    660716                if self.currList == "configlist" or self.currList == "suggestionslist":
    661717                        self["config"].invalidateCurrent()
     
    840896                        if not append:
    841897                                self[self.currList].setIndex(0)
     898                        self["feedlist"].updateList(self.videolist)
    842899                else:
    843900                        self.setState('noVideos')
     
    919976                if feed is not None:
    920977                        self.ytfeed = feed
    921                 self.loadPreviewpics()
     978                self.buildEntryList()
    922979
    923980        def getNextEntries(self, result):
     
    934991                        print "RELATEDURL--->",myurl
    935992                        if myurl is not None:
     993                                self.appendEntries = False
    936994                                self.getFeed(myurl, _("Related video entries."))
    937995
     
    941999                        print "RESPONSEURL--->",myurl
    9421000                        if myurl is not None:
     1001                                self.appendEntries = False
    9431002                                self.getFeed(myurl, _("Response video entries."))
    9441003
     
    9681027                if self.FirstRun == True:       
    9691028                        self.FirstRun = False
    970                 self.loadPreviewpics()
    971 
    972         def loadPreviewpics(self):
    973                 self.thumbnails = []
     1029                self.buildEntryList()
     1030
     1031        def buildEntryList(self):
    9741032                self.mytubeentries = None
    975                 self.index = 0
     1033                self.screenshotList = []
    9761034                self.maxentries = 0
    977                 self.picloads = {}
    9781035                self.mytubeentries = myTubeService.getEntries()
    9791036                self.maxentries = len(self.mytubeentries)-1
    9801037                if self.mytubeentries and len(self.mytubeentries):
    981                         currindex = 0
    982                         for entry in self.mytubeentries:
    983                                 TubeID = entry.getTubeId()
    984                                 thumbnailFile = "/tmp/" + str(TubeID) + ".jpg"
    985                                 currPic = [currindex,TubeID,thumbnailFile,None]
    986                                 self.thumbnails.append(currPic)
    987                                 thumbnailUrl = None
    988                                 thumbnailUrl = entry.getThumbnailUrl(0)
    989                                 if thumbnailUrl is not None:
    990                                         client.downloadPage(thumbnailUrl,thumbnailFile).addCallback(self.fetchFinished,currindex,str(TubeID)).addErrback(self.fetchFailed,currindex,str(TubeID))
    991                                 currindex +=1
    992                 else:
     1038                        if self.appendEntries == False:
     1039                                self.videolist = []
     1040                                for entry in self.mytubeentries:
     1041                                        TubeID = entry.getTubeId()
     1042                                        thumbnailUrl = None
     1043                                        thumbnailUrl = entry.getThumbnailUrl(0)                         
     1044                                        if thumbnailUrl is not None:
     1045                                                self.screenshotList.append((TubeID,thumbnailUrl))
     1046                                        if not self.Details.has_key(TubeID):
     1047                                                self.Details[TubeID] = { 'thumbnail': None}
     1048                                        self.videolist.append(self.buildEntryComponent(entry, TubeID))
     1049                                if len(self.videolist):
     1050                                        self["feedlist"].style = "default"
     1051                                        self["feedlist"].disable_callbacks = True
     1052                                        self["feedlist"].list = self.videolist
     1053                                        self["feedlist"].disable_callbacks = False
     1054                                        self["feedlist"].setIndex(0)
     1055                                        self["feedlist"].setList(self.videolist)
     1056                                        self["feedlist"].updateList(self.videolist)
     1057                                        if self.FirstRun == True:       
     1058                                                self.switchToConfigList()
     1059                                        else:
     1060                                                self.switchToFeedList()
     1061                        else:           
     1062                                self.oldfeedentrycount = self["feedlist"].count()
     1063                                for entry in self.mytubeentries:
     1064                                        TubeID = entry.getTubeId()
     1065                                        thumbnailUrl = None
     1066                                        thumbnailUrl = entry.getThumbnailUrl(0)                         
     1067                                        if thumbnailUrl is not None:
     1068                                                self.screenshotList.append((TubeID,thumbnailUrl))
     1069                                        if not self.Details.has_key(TubeID):
     1070                                                self.Details[TubeID] = { 'thumbnail': None}
     1071                                        self.videolist.append(self.buildEntryComponent(entry, TubeID))
     1072                                if len(self.videolist):
     1073                                        self["feedlist"].style = "default"
     1074                                        old_index = self["feedlist"].index
     1075                                        self["feedlist"].disable_callbacks = True
     1076                                        self["feedlist"].list = self.videolist
     1077                                        self["feedlist"].disable_callbacks = False
     1078                                        self["feedlist"].setList(self.videolist)
     1079                                        self["feedlist"].setIndex(old_index)
     1080                                        self["feedlist"].updateList(self.videolist)
     1081                                        self["feedlist"].selectNext()
     1082                                        self.switchToFeedList(True)
     1083                        if not self.timer_startDownload.isActive():
     1084                                print "STARRTDOWNLOADTIMER IM BUILDENTRYLIST"
     1085                                self.timer_startDownload.start(5)
     1086                else:
     1087                        self.setState('Error')
    9931088                        pass
    994 
    995         def fetchFailed(self, string, index, id):
    996                 print "[fetchFailed] for index:" + str(index) + "for YoutubeID:" + id + string.getErrorMessage()
    997 
    998         def fetchFinished(self, string, index, id):
    999                 print "[fetchFinished] for index:" + str(index) + " for YoutubeID:" + id
    1000                 self.decodePic(index)
    1001 
    1002         def decodePic(self, index):
    1003                 sc = AVSwitch().getFramebufferScale()
    1004                 self.picloads[index] = ePicLoad()
    1005                 self.picloads[index].PictureData.get().append(boundFunction(self.finish_decode, index))
    1006                 for entry in self.thumbnails:
    1007                         if entry[0] == index:
    1008                                 self.index = index
    1009                                 thumbnailFile = entry[2]
    1010                                 if (os_path.exists(thumbnailFile) == True):
    1011                                         #print "[decodePic] DECODING THUMBNAIL for INDEX:"+  str(self.index) + "and file: " + thumbnailFile
    1012                                         self.picloads[index].setPara((self["thumbnail"].instance.size().width(), self["thumbnail"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000"))
    1013                                         self.picloads[index].startDecode(thumbnailFile)
    1014                                 else:
    1015                                         print "[decodePic] Thumbnail file NOT FOUND !!!-->:",thumbnailFile
    1016 
    1017         def finish_decode(self, picindex = None, picInfo=None):
    1018                 #print "finish_decode - of INDEX", picindex
    1019                 ptr = self.picloads[picindex].getData()
    1020                 if ptr != None:
    1021                         print ptr
    1022                         self.thumbnails[picindex][3] = ptr
    1023                         if (os_path.exists(self.thumbnails[picindex][2]) == True):
    1024                                 #print "removing", self.thumbnails[picindex][2]
    1025                                 remove(self.thumbnails[picindex][2])
    1026                                 del self.picloads[picindex]
    1027                                 if len(self.picloads) == 0:
    1028                                         self.timer.startLongTimer(3)
    1029 
    1030         def picloadTimeout(self):
    1031                 self.timer.stop()
    1032                 if len(self.picloads) == 0:
    1033                                 print "all decodes should be now really finished"
    1034                                 self.buildEntryList()
    1035                 else:
    1036                         self.timer.startLongTimer(2)
    1037 
    1038         def buildEntryList(self):
    1039                 myindex = 0
    1040                 if self.appendEntries == False:
    1041                         self.videolist = []
    1042                         for entry in self.mytubeentries:
    1043                                 self.videolist.append(self.buildEntryComponent(entry, myindex))
    1044                                 myindex +=1
    1045                         if len(self.videolist):
    1046                                 self["feedlist"].style = "default"
    1047                                 self["feedlist"].disable_callbacks = True
    1048                                 self["feedlist"].list = self.videolist
    1049                                 self["feedlist"].disable_callbacks = False
    1050                                 self["feedlist"].setIndex(0)
    1051                                 self["feedlist"].setList(self.videolist)
    1052                                 self["feedlist"].updateList(self.videolist)
    1053                                 if self.FirstRun == True:       
    1054                                         self.switchToConfigList()
    1055                                 else:
    1056                                         self.switchToFeedList()
    1057                 else:           
    1058                         self.oldfeedentrycount = self["feedlist"].count()
    1059                         for entry in self.mytubeentries:
    1060                                 self.videolist.append(self.buildEntryComponent(entry, myindex))
    1061                                 myindex +=1
    1062                         if len(self.videolist):
    1063                                 self["feedlist"].style = "default"
    1064                                 old_index = self["feedlist"].index
    1065                                 self["feedlist"].disable_callbacks = True
    1066                                 self["feedlist"].list = self.videolist
    1067                                 self["feedlist"].disable_callbacks = False
    1068                                 self["feedlist"].setList(self.videolist)
    1069                                 self["feedlist"].setIndex(old_index)
    1070                                 self["feedlist"].updateList(self.videolist)
    1071                                 self["feedlist"].selectNext()
    1072                                 self.switchToFeedList(True)
    1073 
    10741089       
    1075         def buildEntryComponent(self, entry, index):
     1090        def buildEntryComponent(self, entry,TubeID):
    10761091                Title = entry.getTitle()
    10771092                print "Titel-->",Title
    10781093                Description = entry.getDescription()
    1079                 TubeID = entry.getTubeId()
     1094                myTubeID = TubeID
    10801095                PublishedDate = entry.getPublishedDate()
    10811096                if PublishedDate is not "unknown":
     
    11011116                else:
    11021117                        ratings = ""
    1103                 thumbnail = self.thumbnails[index][3]
    1104                 return((entry, Title, Description, TubeID, thumbnail, _("Added: ") + str(published), _("Views: ") + str(views), _("Duration: ") + str(duration), _("Ratings: ") + str(ratings) ))       
     1118                thumbnail = None
     1119                if self.Details[myTubeID]["thumbnail"]:
     1120                        thumbnail = self.Details[myTubeID]["thumbnail"]
     1121                return((entry, Title, Description, myTubeID, thumbnail, _("Added: ") + str(published), _("Views: ") + str(views), _("Duration: ") + str(duration), _("Ratings: ") + str(ratings) ))     
    11051122
    11061123        def getNextEntry(self):
     
    11451162        def showVideoInfo(self):
    11461163                if self.currList == "feedlist":
    1147                         cmd = "rm -rf /tmp/*.jpg"
    1148                         if self.CleanupConsole is None:
    1149                                 self.CleanupConsole = Console()
    1150                         self.CleanupConsole.ePopen(cmd, self.openInfoScreen)
    1151        
    1152         def openInfoScreen(self, result, retval,extra_args):
     1164                        self.openInfoScreen()
     1165
     1166        def openInfoScreen(self):
    11531167                if self.currList == "feedlist":
    11541168                        current = self[self.currList].getCurrent()
     
    11591173                                        videoinfos = myentry.PrintEntryDetails()
    11601174                                        self.session.open(MyTubeVideoInfoScreen, self.skin_path, videoinfo = videoinfos )
    1161                
     1175
     1176        def downloadThumbnails(self):
     1177                self.timer_startDownload.stop()
     1178                for entry in self.screenshotList:
     1179                        thumbnailUrl = entry[1]
     1180                        tubeid = entry[0]
     1181                        thumbnailFile = "/tmp/"+str(tubeid)+".jpg"
     1182                        if self.Details.has_key(tubeid):
     1183                                if self.Details[tubeid]["thumbnail"] is None:
     1184                                        if thumbnailUrl is not None:
     1185                                                if tubeid not in self.pixmaps_to_load:
     1186                                                        self.pixmaps_to_load.append(tubeid)
     1187                                                        if (os_path.exists(thumbnailFile) == True):
     1188                                                                self.fetchFinished(False,tubeid)
     1189                                                        else:
     1190                                                                client.downloadPage(thumbnailUrl,thumbnailFile).addCallback(self.fetchFinished,str(tubeid)).addErrback(self.fetchFailed,str(tubeid))
     1191                                        else:
     1192                                                if tubeid not in self.pixmaps_to_load:
     1193                                                        self.pixmaps_to_load.append(tubeid)
     1194                                                        self.fetchFinished(False,tubeid, failed = True)
     1195
     1196        def fetchFailed(self,string,tubeid):
     1197                print "thumbnail-fetchFailed for: ",tubeid,string.getErrorMessage()
     1198                self.fetchFinished(False,tubeid, failed = True)
     1199
     1200        def fetchFinished(self,x,tubeid, failed = False):
     1201                print "thumbnail-fetchFinished for:",tubeid
     1202                self.pixmaps_to_load.remove(tubeid)
     1203                if failed:
     1204                        thumbnailFile = resolveFilename(SCOPE_CURRENT_PLUGIN, "Extensions/MyTube/plugin.png")
     1205                else:
     1206                        thumbnailFile = "/tmp/"+str(tubeid)+".jpg"
     1207                sc = AVSwitch().getFramebufferScale()
     1208                if (os_path.exists(thumbnailFile) == True):
     1209                        self.picloads[tubeid] = ePicLoad()
     1210                        self.picloads[tubeid].PictureData.get().append(boundFunction(self.finish_decode, tubeid))
     1211                        self.picloads[tubeid].setPara((self["thumbnail"].instance.size().width(), self["thumbnail"].instance.size().height(), sc[0], sc[1], False, 1, "#00000000"))
     1212                        self.picloads[tubeid].startDecode(thumbnailFile)
     1213                else:
     1214                        self.pixmaps_to_load.append(tubeid)
     1215                        self.fetchFinished(False,tubeid, failed = True)
     1216
     1217        def finish_decode(self,tubeid,info):
     1218                print "thumbnail finish_decode:", tubeid,info
     1219                ptr = self.picloads[tubeid].getData()
     1220                thumbnailFile = "/tmp/"+str(tubeid)+".jpg"
     1221                if ptr != None:
     1222                        if self.Details.has_key(tubeid):
     1223                                self.Details[tubeid]["thumbnail"] = ptr
     1224                        if (os_path.exists(thumbnailFile) == True):
     1225                                remove(thumbnailFile)
     1226                        del self.picloads[tubeid]
     1227                else:
     1228                        del self.picloads[tubeid]
     1229                        if self.Details.has_key(tubeid):
     1230                                self.Details[tubeid]["thumbnail"] = None
     1231                self.timer_thumbnails.start(1)
     1232
     1233        def updateFeedThumbnails(self):
     1234                self.timer_thumbnails.stop()
     1235                if len(self.picloads) != 0:
     1236                        self.timer_thumbnails.start(1)
     1237                else:
     1238                        idx = 0
     1239                        for entry in self.videolist:
     1240                                tubeid = entry[3]
     1241                                if self.Details.has_key(tubeid):
     1242                                        if self.Details[tubeid]["thumbnail"] is not None:
     1243                                                thumbnail = entry[4]
     1244                                                if thumbnail == None:
     1245                                                        myentry = entry[0]
     1246                                                        self.videolist[idx] = self.buildEntryComponent(myentry, tubeid )
     1247                                idx += 1
     1248                        if self.currList == "feedlist":
     1249                                self["feedlist"].updateList(self.videolist)             
     1250
    11621251
    11631252class MyTubeVideoInfoScreen(Screen):
    11641253        skin = """
    1165                 <screen name="MyTubeVideoInfoScreen" flags="wfNoBorder" position="center,center" size="720,576" title="MyTubePlayerMainScreen..." >
    1166                         <eLabel backgroundColor="#32000000" position="0,0" size="720,576" zPosition="-1"/>
     1254                <screen name="MyTubeVideoInfoScreen" flags="wfNoBorder" position="0,0" size="720,576" title="MyTubePlayerMainScreen..." >
     1255                        <ePixmap position="0,0" zPosition="-1" size="720,576" pixmap="~/mytubemain_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
    11671256                        <widget name="title" position="60,50" size="600,50" zPosition="5" valign="center" halign="left" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
    11681257                        <widget name="starsbg" pixmap="~/starsbar_empty.png" position="560,220" zPosition="5" size="100,20" transparent="1" alphatest="on" />
     
    13351424                ptr = self.picloads[picindex].getData()
    13361425                if ptr != None:
    1337                         print ptr
    13381426                        self.thumbnails[picindex][3] = ptr
    13391427                        if (os_path.exists(self.thumbnails[picindex][2]) == True):
     
    13471435                self.timer.stop()
    13481436                if len(self.picloads) == 0:
    1349                                 print "all decodes should be now really finished"
    13501437                                self.buildInfoList()
    13511438                else:
     
    13531440
    13541441        def buildInfoList(self):
    1355                 print "blasel"
    13561442                self.infolist = []
    13571443                Thumbail0 = None
     
    13801466class MyTubeVideoHelpScreen(Screen):
    13811467        skin = """
    1382                 <screen name="MyTubeVideoHelpScreen" flags="wfNoBorder" position="center,center" size="720,576" title="MyTubePlayerMainScreen..." >
    1383                         <eLabel backgroundColor="#32000000" position="0,0" size="720,576" zPosition="-1"/>
     1468                <screen name="MyTubeVideoHelpScreen" flags="wfNoBorder" position="0,0" size="720,576" title="MyTubePlayerMainScreen..." >
     1469                        <ePixmap position="0,0" zPosition="-1" size="720,576" pixmap="~/mytubemain_bg.png" alphatest="on" transparent="1" backgroundColor="transparent"/>
    13841470                        <widget name="title" position="60,50" size="600,50" zPosition="5" valign="center" halign="left" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
    13851471                        <widget name="detailtext" position="60,120" size="610,370" zPosition="10" font="Regular;21" transparent="1" halign="left" valign="top"/>
    13861472                        <ePixmap position="100,500" size="100,40" zPosition="0" pixmap="~/plugin.png" alphatest="on" transparent="1" />
    1387                         <eLabel backgroundColor="red" position="220,500" size="140,3" zPosition="4"/>
     1473                        <ePixmap position="220,500" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
    13881474                        <widget name="key_red" position="220,500" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
    13891475                </screen>"""
     
    14391525        ALLOW_SUSPEND = True
    14401526
    1441         skin = """<screen name="MyTubePlayer" flags="wfNoBorder" position="center,380" size="720,160" title="InfoBar" backgroundColor="transparent">
    1442                 <eLabel backgroundColor="#32000000" position="0,0" size="720,160" zPosition="-1"/>
     1527        skin = """<screen name="MyTubePlayer" flags="wfNoBorder" position="0,380" size="720,160" title="InfoBar" backgroundColor="transparent">
     1528                <ePixmap position="0,0" pixmap="skin_default/info-bg_mp.png" zPosition="-1" size="720,160" />
    14431529                <ePixmap position="29,40" pixmap="skin_default/screws_mp.png" size="665,104" alphatest="on" />
    14441530                <ePixmap position="48,70" pixmap="skin_default/icons/mp_buttons.png" size="108,13" alphatest="on" />
     
    15781664                                self.__setHideTimer()   
    15791665                self.state = self.STATE_PLAYING
    1580                 print "self.state--->",self.state
    15811666                self.session.nav.playService(self.service)
    15821667                if self.shown:
     
    15861671                print "stopCurrent"
    15871672                self.session.nav.stopService()
    1588                 #if self.state == self.STATE_IDLE:
    1589                 #       return
    15901673                self.state = self.STATE_IDLE
    1591                 print "self.state--->",self.state
    1592                
    15931674
    15941675        def playpauseService(self):
    15951676                print "playpauseService"
    1596                 #print "self.state--->",self.state
    15971677                if self.state == self.STATE_PLAYING:
    15981678                        self.pauseService()
     
    16031683                print "pauseService"
    16041684                if self.state == self.STATE_PLAYING:
    1605                         #print "self.state--->",self.state
    1606                         print "calling setseekstate pause"
    16071685                        self.setSeekState(self.STATE_PAUSED)
    16081686               
     
    16101688                print "unPauseService"
    16111689                if self.state == self.STATE_PAUSED:
    1612                         #print "self.state--->",self.state
    1613                         print "calling setseekstate playing"
    16141690                        self.setSeekState(self.STATE_PLAYING)
    16151691
     
    16351711                print "seekable status changed!"
    16361712                if not self.isSeekable():
    1637                         #self["SeekActions"].setEnabled(False)
    1638                         print "not seekable, return to play"
    16391713                        self.setSeekState(self.STATE_PLAYING)
    16401714                else:
    1641 #                       self["SeekActions"].setEnabled(True)
    16421715                        print "seekable"
    16431716
     
    16481721        def setSeekState(self, wantstate):
    16491722                print "setSeekState"
    1650                 #print "current state--->",self.state
    1651                 #print " wanted state--->",wantstate
    16521723                if wantstate == self.STATE_PAUSED:
    16531724                        print "trying to switch to Pause- state:",self.STATE_PAUSED
     
    16671738                        if wantstate == self.STATE_PAUSED:
    16681739                                print "WANT TO PAUSE"
    1669                                 print "current state --->",self.state
    1670                                 print "wanted state  --->",wantstate
    16711740                                pauseable.pause()
    16721741                                self.state = self.STATE_PAUSED
     
    16761745                        elif wantstate == self.STATE_PLAYING:
    16771746                                print "WANT TO PLAY"
    1678                                 print "current state --->",self.state
    1679                                 print "wanted state  --->",wantstate
    16801747                                pauseable.unpause()
    16811748                                self.state = self.STATE_PLAYING
     
    17091776        def leavePlayerConfirmed(self, answer):
    17101777                answer = answer and answer[1]
    1711                 print "ANSWER im player leave",answer
    17121778                if answer == "quit":
    17131779                        self.close()
     
    17281794
    17291795def MyTubeMain(session, **kwargs):
    1730         Console().ePopen(("rm -rf /tmp/*.jpg"))
    1731         session.open(MyTubePlayerMainScreen)
     1796        l2 = False
     1797        l2cert = etpm.getCert(eTPM.TPMD_DT_LEVEL2_CERT)
     1798        if l2cert is None:
     1799                print "l2cert not found"
     1800                return
     1801       
     1802        l2key = validate_cert(l2cert, rootkey)
     1803        if l2key is None:
     1804                print "l2cert invalid"
     1805                return
     1806        l2 = True
     1807        if l2:
     1808                session.open(MyTubePlayerMainScreen,l2key)
    17321809
    17331810
Note: See TracChangeset for help on using the changeset viewer.