示例#1
0
 def getCustomActions(self, Index=0):
     retCode = RetHost.ERROR
     retlist = []
     if self.useWatchedFlag:
         ret = self.cachedRet
         if ret.value[Index].type in [
                 CDisplayListItem.TYPE_VIDEO, CDisplayListItem.TYPE_AUDIO
         ]:
             tmp = self.getItemHashData(Index, ret.value[Index])
             if tmp != '':
                 if self.cachedRet.value[Index].isWatched:
                     params = IPTVChoiceBoxItem(
                         _('Unset watched'), "", {
                             'action': 'unset_watched_flag',
                             'item_index': Index,
                             'hash_data': tmp
                         })
                 else:
                     params = IPTVChoiceBoxItem(
                         _('Set watched'), "", {
                             'action': 'set_watched_flag',
                             'item_index': Index,
                             'hash_data': tmp
                         })
                 retlist.append(params)
             retCode = RetHost.OK
     return RetHost(retCode, value=retlist)
示例#2
0
 def getCustomActions(self, Index = 0):
     retCode = RetHost.ERROR
     retlist = []
     
     def addPasteAction(path):
         if os_path.isdir(path):
             if '' != self.cFilePath:
                 cutPath, cutFileName = os_path.split(self.cFilePath)
                 params = IPTVChoiceBoxItem(_('Paste "%s"') % cutFileName, "", {'action':'paste_file', 'path':path})
                 retlist.append(params)
     
     ok = False
     if not self.isValidIndex(Index):
         path = self.host.getCurrDir()
         addPasteAction(path)
         retCode = RetHost.OK 
         return RetHost(retCode, value=retlist)
     
     if self.host.currList[Index]['type'] in ['video', 'audio', 'picture'] and \
        self.host.currList[Index].get('url', '').startswith('file://'):
         fullPath = self.host.currList[Index]['url'][7:]
         ok = True
     elif self.host.currList[Index].get("category", '') == 'm3u':
         fullPath = self.host.currList[Index]['path']
         ok = True
     elif self.host.currList[Index].get("category", '') == 'dir':
         fullPath = self.host.currList[Index]['path']
         ok = True
     elif self.host.currList[Index].get("category", '') == 'iso':
         fullPath = self.host.currList[Index]['path']
         ok = True
     if ok:
         path, fileName = os_path.split(fullPath)
         name, ext = os_path.splitext(fileName)
         
         if '' != self.host.currList[Index].get("iso_mount_path", ''):
             params = IPTVChoiceBoxItem(_('Umount iso file'), "", {'action':'umount_iso_file', 'file_path':fullPath, 'iso_mount_path':self.host.currList[Index]['iso_mount_path']})
             retlist.append(params)
         
         if os_path.isfile(fullPath):
             params = IPTVChoiceBoxItem(_('Rename'), "", {'action':'rename_file', 'file_path':fullPath})
             retlist.append(params)
             params = IPTVChoiceBoxItem(_('Remove'), "", {'action':'remove_file', 'file_path':fullPath})
             retlist.append(params)
             
             params = IPTVChoiceBoxItem(_('Copy'), "", {'action':'copy_file', 'file_path':fullPath})
             retlist.append(params)
             
             params = IPTVChoiceBoxItem(_('Cut'), "", {'action':'cut_file', 'file_path':fullPath})
             retlist.append(params)
         
         addPasteAction(path)
         retCode = RetHost.OK
     
     return RetHost(retCode, value = retlist)
 def addPasteAction(path):
     if os_path.isdir(path):
         if '' != self.cFilePath:
             cutPath, cutFileName = os_path.split(self.cFilePath)
             params = IPTVChoiceBoxItem(
                 _('Paste "%s"') % cutFileName, "", {
                     'action': 'paste_file',
                     'path': path
                 })
             retlist.append(params)