- Timestamp:
- Aug 19, 2011, 9:48:11 AM (15 years ago)
- 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 _2 1 from Plugins.Plugin import PluginDescriptor 3 from MyTubeService import GoogleSuggestions 2 from MyTubeService import GoogleSuggestions, validate_cert, get_rnd 4 3 from MyTubeSearch import ConfigTextWithGoogleSuggestions 5 4 from Tools.BoundFunction import boundFunction … … 30 29 from threading import Condition 31 30 32 from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_HDD 31 from Tools.Directories import pathExists, fileExists, resolveFilename, SCOPE_PLUGINS, SCOPE_SKIN_IMAGE, SCOPE_HDD, SCOPE_CURRENT_PLUGIN 33 32 from Tools.LoadPixmap import LoadPixmap 34 33 from Tools.Downloader import HTTPProgressDownloader, downloadWithProgress … … 40 39 41 40 from Screens.InfoBarGenerics import InfoBarShowHide, InfoBarSeek, InfoBarNotifications, InfoBarServiceNotifications 41 from __init__ import bin2long, long2bin, rsa_pub1024, decrypt_block 42 43 44 45 class 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 54 def decrypt_block(a,b): 55 return 80*"-" + a 56 def get_rnd(): 57 return "12345678" 58 def validate_cert(*args): 59 return "12345678" 60 61 etpm = eTPM() 62 rootkey = ['\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', ':', '?'] 42 63 43 64 config.plugins.mytube = ConfigSubsection() … … 124 145 [ 125 146 ("hd", _("HD videos")), 126 ("most_viewed", _("Most viewed")),147 # ("most_viewed", _("Most viewed")), 127 148 ("top_rated", _("Top rated")), 128 149 ("recently_featured", _("Recently featured")), … … 132 153 ("most_responded", _("Most responded")), 133 154 ("most_recent", _("Most recent")) 134 ], " most_viewed")155 ], "top_rated") 135 156 config.plugins.mytube.general.on_movie_stop = ConfigSelection(default = "ask", choices = [ 136 157 ("ask", _("Ask user")), ("quit", _("Return to movie list")), ("playnext", _("Play next video")), ("playagain", _("Play video again")) ]) … … 193 214 class MyTubePlayerMainScreen(Screen, ConfigListScreen): 194 215 BASE_STD_FEEDURL = "http://gdata.youtube.com/feeds/api/standardfeeds/" 216 Details = {} 195 217 #(entry, Title, Description, TubeID, thumbnail, PublishedDate,Views,duration,ratings ) 196 218 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" > 201 223 <convert type="TemplatedMultiContent"> 202 224 {"templates": … … 223 245 <ePixmap pixmap="skin_default/buttons/key_menu.png" position="50,520" zPosition="4" size="35,25" alphatest="on" transparent="1" /> 224 246 <ePixmap position="90,500" size="100,40" zPosition="4" pixmap="~/plugin.png" alphatest="on" transparent="1" /> 225 <e Label backgroundColor="red" position="190,500" size="140,3" zPosition="4"/>226 <e Label backgroundColor="green" position="330,500" size="140,3" zPosition="4"/>227 <e Label 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" /> 228 250 <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" /> 229 251 <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" /> … … 235 257 </screen>""" 236 258 237 def __init__(self, session ):259 def __init__(self, session, l2key): 238 260 Screen.__init__(self, session) 239 261 self.session = session 262 self.l2key = l2key 263 self.l3key = None 240 264 self.skin_path = plugin_path 241 265 self.FeedURL = None … … 243 267 self.currentFeedName = None 244 268 self.videolist = [] 245 self.thumbnails = [] 269 246 270 self.video_playlist = [] 247 271 self.statuslist = [] 248 272 self.mytubeentries = None 273 274 self.thumbnails = [] 249 275 self.index = 0 250 276 self.maxentries = 0 277 278 self.screenshotList = [] 279 self.pixmaps_to_load = [] 251 280 self.picloads = {} 281 252 282 self.oldfeedentrycount = 0 253 283 self.appendEntries = False … … 261 291 self.currList = "configlist" 262 292 self.oldlist = None 263 self.CleanupConsole = None 293 264 294 self["feedlist"] = List(self.videolist) 265 295 self["thumbnail"] = Pixmap() … … 345 375 self["statusactions"].setEnabled(False) 346 376 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 349 383 self.SearchConfigEntry = None 350 384 self.searchContextEntries = [] … … 360 394 def __onClose(self): 361 395 del self.Timer 362 del self.timer 396 del self.timer_startDownload 397 del self.timer_thumbnails 398 self.Details = {} 363 399 self.session.nav.playService(self.lastservice) 364 400 365 401 def layoutFinished(self): 366 402 self.currList = "status" 367 #self["key_green"].hide()368 403 current = self["config"].getCurrent() 369 404 if current[1].help_window.instance is not None: 370 405 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 376 444 def TimerFire(self): 377 445 self.Timer.stop() … … 393 461 def setState(self,status = None): 394 462 if status: 395 if self.FirstRun == True:396 self.appendEntries = False397 myTubeService.startService()398 463 self.currList = "status" 399 self.statuslist = []400 464 self["videoactions"].setEnabled(False) 401 465 self["searchactions"].setEnabled(False) 402 #self["key_green"].hide()403 466 self["config_actions"].setEnabled(False) 404 467 self["historyactions"].setEnabled(False) … … 406 469 self["ButtonBlue"].hide() 407 470 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!" ) )) 414 483 self["feedlist"].style = "state" 415 484 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() 419 507 self["feedlist"].style = "state" 420 508 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)) 444 516 445 517 … … 467 539 468 540 def handleMenu(self): 469 print "currlist im HandleMenu:",self.currList470 541 if self.currList == "configlist": 471 542 menulist = ( … … 492 563 def openMenu(self, answer): 493 564 answer = answer and answer[1] 494 print "openMenu - ANSWER",answer495 565 if answer == "settings": 496 566 print "settings selected" … … 519 589 self.session.open(MyTubeTasksScreen, self.skin_path , self.tasklist) 520 590 elif answer == None: 521 print "No menuentry selected, we should just switch back to old state."522 591 self.ScreenClosed() 523 592 … … 530 599 if self.currList == "historylist": 531 600 if self.HistoryWindow.status() is False: 532 print "status is FALSE"533 601 self.HistoryWindow.activate() 534 602 self.HistoryWindow.instance.show() … … 553 621 def openStandardFeedClosed(self, answer): 554 622 answer = answer and answer[1] 555 print "openStandardFeedClosed - ANSWER",answer556 623 if answer is not None: 557 624 if answer == 'hd': … … 583 650 584 651 def leavePlayer(self): 585 print " self.currList im leavePlayer",self.currList652 print "leavePlayer" 586 653 if self.HistoryWindow is not None: 587 654 self.HistoryWindow.deactivate() … … 602 669 def leavePlayerConfirmed(self, answer): 603 670 answer = answer and answer[1] 604 print "ANSWER",answer605 671 if answer == "quit": 606 cmd = "rm -rf /tmp/*.jpg" 607 self.CleanupConsole = Console() 608 self.CleanupConsole.ePopen(cmd, self.doQuit) 672 self.doQuit() 609 673 elif answer == "continue": 610 674 if self.currList == "historylist": 611 675 if self.HistoryWindow.status() is False: 612 print "status is FALSE"613 676 self.HistoryWindow.activate() 614 677 self.HistoryWindow.instance.show() … … 622 685 self.switchToConfigList() 623 686 elif answer == None: 624 print "No menuentry selected, we should just switch back to old state."625 687 if self.currList == "historylist": 626 688 if self.HistoryWindow.status() is False: 627 print "status is FALSE"628 689 self.HistoryWindow.activate() 629 690 self.HistoryWindow.instance.show() … … 633 694 self.switchToFeedList() 634 695 635 def doQuit(self , result, retval,extra_args):696 def doQuit(self): 636 697 if self["config"].getCurrent()[1].suggestionsWindow is not None: 637 698 self.session.deleteDialog(self["config"].getCurrent()[1].suggestionsWindow) … … 641 702 config.plugins.mytube.general.showHelpOnOpen.value = False 642 703 config.plugins.mytube.general.showHelpOnOpen.save() 643 print "self.History im doQuit:",self.History644 704 if not config.plugins.mytube.general.clearHistoryOnClose.value: 645 705 if self.History and len(self.History): … … 650 710 config.plugins.mytube.general.save() 651 711 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)656 712 self.close() 657 713 658 714 def keyOK(self): 659 print "self.currList ----->",self.currList715 print "self.currList im KeyOK",self.currList 660 716 if self.currList == "configlist" or self.currList == "suggestionslist": 661 717 self["config"].invalidateCurrent() … … 840 896 if not append: 841 897 self[self.currList].setIndex(0) 898 self["feedlist"].updateList(self.videolist) 842 899 else: 843 900 self.setState('noVideos') … … 919 976 if feed is not None: 920 977 self.ytfeed = feed 921 self. loadPreviewpics()978 self.buildEntryList() 922 979 923 980 def getNextEntries(self, result): … … 934 991 print "RELATEDURL--->",myurl 935 992 if myurl is not None: 993 self.appendEntries = False 936 994 self.getFeed(myurl, _("Related video entries.")) 937 995 … … 941 999 print "RESPONSEURL--->",myurl 942 1000 if myurl is not None: 1001 self.appendEntries = False 943 1002 self.getFeed(myurl, _("Response video entries.")) 944 1003 … … 968 1027 if self.FirstRun == True: 969 1028 self.FirstRun = False 970 self.loadPreviewpics() 971 972 def loadPreviewpics(self): 973 self.thumbnails = [] 1029 self.buildEntryList() 1030 1031 def buildEntryList(self): 974 1032 self.mytubeentries = None 975 self. index = 01033 self.screenshotList = [] 976 1034 self.maxentries = 0 977 self.picloads = {}978 1035 self.mytubeentries = myTubeService.getEntries() 979 1036 self.maxentries = len(self.mytubeentries)-1 980 1037 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') 993 1088 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:" + id1000 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 = index1009 thumbnailFile = entry[2]1010 if (os_path.exists(thumbnailFile) == True):1011 #print "[decodePic] DECODING THUMBNAIL for INDEX:"+ str(self.index) + "and file: " + thumbnailFile1012 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 !!!-->:",thumbnailFile1016 1017 def finish_decode(self, picindex = None, picInfo=None):1018 #print "finish_decode - of INDEX", picindex1019 ptr = self.picloads[picindex].getData()1020 if ptr != None:1021 print ptr1022 self.thumbnails[picindex][3] = ptr1023 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 = 01040 if self.appendEntries == False:1041 self.videolist = []1042 for entry in self.mytubeentries:1043 self.videolist.append(self.buildEntryComponent(entry, myindex))1044 myindex +=11045 if len(self.videolist):1046 self["feedlist"].style = "default"1047 self["feedlist"].disable_callbacks = True1048 self["feedlist"].list = self.videolist1049 self["feedlist"].disable_callbacks = False1050 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 +=11062 if len(self.videolist):1063 self["feedlist"].style = "default"1064 old_index = self["feedlist"].index1065 self["feedlist"].disable_callbacks = True1066 self["feedlist"].list = self.videolist1067 self["feedlist"].disable_callbacks = False1068 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 1074 1089 1075 def buildEntryComponent(self, entry, index):1090 def buildEntryComponent(self, entry,TubeID): 1076 1091 Title = entry.getTitle() 1077 1092 print "Titel-->",Title 1078 1093 Description = entry.getDescription() 1079 TubeID = entry.getTubeId()1094 myTubeID = TubeID 1080 1095 PublishedDate = entry.getPublishedDate() 1081 1096 if PublishedDate is not "unknown": … … 1101 1116 else: 1102 1117 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) )) 1105 1122 1106 1123 def getNextEntry(self): … … 1145 1162 def showVideoInfo(self): 1146 1163 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): 1153 1167 if self.currList == "feedlist": 1154 1168 current = self[self.currList].getCurrent() … … 1159 1173 videoinfos = myentry.PrintEntryDetails() 1160 1174 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 1162 1251 1163 1252 class MyTubeVideoInfoScreen(Screen): 1164 1253 skin = """ 1165 <screen name="MyTubeVideoInfoScreen" flags="wfNoBorder" position=" center,center" size="720,576" title="MyTubePlayerMainScreen..." >1166 <e Label 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"/> 1167 1256 <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" /> 1168 1257 <widget name="starsbg" pixmap="~/starsbar_empty.png" position="560,220" zPosition="5" size="100,20" transparent="1" alphatest="on" /> … … 1335 1424 ptr = self.picloads[picindex].getData() 1336 1425 if ptr != None: 1337 print ptr1338 1426 self.thumbnails[picindex][3] = ptr 1339 1427 if (os_path.exists(self.thumbnails[picindex][2]) == True): … … 1347 1435 self.timer.stop() 1348 1436 if len(self.picloads) == 0: 1349 print "all decodes should be now really finished"1350 1437 self.buildInfoList() 1351 1438 else: … … 1353 1440 1354 1441 def buildInfoList(self): 1355 print "blasel"1356 1442 self.infolist = [] 1357 1443 Thumbail0 = None … … 1380 1466 class MyTubeVideoHelpScreen(Screen): 1381 1467 skin = """ 1382 <screen name="MyTubeVideoHelpScreen" flags="wfNoBorder" position=" center,center" size="720,576" title="MyTubePlayerMainScreen..." >1383 <e Label 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"/> 1384 1470 <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" /> 1385 1471 <widget name="detailtext" position="60,120" size="610,370" zPosition="10" font="Regular;21" transparent="1" halign="left" valign="top"/> 1386 1472 <ePixmap position="100,500" size="100,40" zPosition="0" pixmap="~/plugin.png" alphatest="on" transparent="1" /> 1387 <e Label 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" /> 1388 1474 <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" /> 1389 1475 </screen>""" … … 1439 1525 ALLOW_SUSPEND = True 1440 1526 1441 skin = """<screen name="MyTubePlayer" flags="wfNoBorder" position=" center,380" size="720,160" title="InfoBar" backgroundColor="transparent">1442 <e Label 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" /> 1443 1529 <ePixmap position="29,40" pixmap="skin_default/screws_mp.png" size="665,104" alphatest="on" /> 1444 1530 <ePixmap position="48,70" pixmap="skin_default/icons/mp_buttons.png" size="108,13" alphatest="on" /> … … 1578 1664 self.__setHideTimer() 1579 1665 self.state = self.STATE_PLAYING 1580 print "self.state--->",self.state1581 1666 self.session.nav.playService(self.service) 1582 1667 if self.shown: … … 1586 1671 print "stopCurrent" 1587 1672 self.session.nav.stopService() 1588 #if self.state == self.STATE_IDLE:1589 # return1590 1673 self.state = self.STATE_IDLE 1591 print "self.state--->",self.state1592 1593 1674 1594 1675 def playpauseService(self): 1595 1676 print "playpauseService" 1596 #print "self.state--->",self.state1597 1677 if self.state == self.STATE_PLAYING: 1598 1678 self.pauseService() … … 1603 1683 print "pauseService" 1604 1684 if self.state == self.STATE_PLAYING: 1605 #print "self.state--->",self.state1606 print "calling setseekstate pause"1607 1685 self.setSeekState(self.STATE_PAUSED) 1608 1686 … … 1610 1688 print "unPauseService" 1611 1689 if self.state == self.STATE_PAUSED: 1612 #print "self.state--->",self.state1613 print "calling setseekstate playing"1614 1690 self.setSeekState(self.STATE_PLAYING) 1615 1691 … … 1635 1711 print "seekable status changed!" 1636 1712 if not self.isSeekable(): 1637 #self["SeekActions"].setEnabled(False)1638 print "not seekable, return to play"1639 1713 self.setSeekState(self.STATE_PLAYING) 1640 1714 else: 1641 # self["SeekActions"].setEnabled(True)1642 1715 print "seekable" 1643 1716 … … 1648 1721 def setSeekState(self, wantstate): 1649 1722 print "setSeekState" 1650 #print "current state--->",self.state1651 #print " wanted state--->",wantstate1652 1723 if wantstate == self.STATE_PAUSED: 1653 1724 print "trying to switch to Pause- state:",self.STATE_PAUSED … … 1667 1738 if wantstate == self.STATE_PAUSED: 1668 1739 print "WANT TO PAUSE" 1669 print "current state --->",self.state1670 print "wanted state --->",wantstate1671 1740 pauseable.pause() 1672 1741 self.state = self.STATE_PAUSED … … 1676 1745 elif wantstate == self.STATE_PLAYING: 1677 1746 print "WANT TO PLAY" 1678 print "current state --->",self.state1679 print "wanted state --->",wantstate1680 1747 pauseable.unpause() 1681 1748 self.state = self.STATE_PLAYING … … 1709 1776 def leavePlayerConfirmed(self, answer): 1710 1777 answer = answer and answer[1] 1711 print "ANSWER im player leave",answer1712 1778 if answer == "quit": 1713 1779 self.close() … … 1728 1794 1729 1795 def 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) 1732 1809 1733 1810
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/openaaf/chrome/common/titannit_trac_banner.png)