Exemple #1
0
    def downloadVideo(self, url, title):
        common.log('Trying to download video ' + str(url))

        # check url
        if url.startswith('plugin'):
            common.log('Video is not downloadable')
            return None

        path = common.getSetting('download_path')
        if not path:
            path = common.browseFolders(common.translate(30017))
            common.setSetting('download_path', path)

        title = getKeyboard(default=fu.cleanFilename(title),
                            heading='SportsDevil')
        if title == None or title == '':
            return None

        downloader = Downloader()
        downloaded_file = downloader.downloadMovie(url, path,
                                                   fu.cleanFilename(title),
                                                   '.flv')

        if downloaded_file == None:
            common.log('Download cancelled')
        else:
            common.log('Video ' + url + " downloaded to '" + downloaded_file +
                       "'")

        return downloaded_file
Exemple #2
0
    def downloadVideo(self, url, title):
        common.log('Trying to download video ' + str(url))

        # check url
        if url.startswith('plugin'):
            common.log('Video is not downloadable')
            return None

        path = common.getSetting('download_path')
        if not path:
            path = common.browseFolders(common.translate(30017))
            common.setSetting('download_path', path)

        title = getKeyboard(default = fu.cleanFilename(title),heading='SportsDevil')
        if title == None or title == '':
            return None

        downloader = Downloader()
        downloaded_file = downloader.downloadMovie(url, path,  fu.cleanFilename(title), '.flv')

        if downloaded_file == None:
            common.log ('Download cancelled')
        else:
            common.log('Video ' + url + " downloaded to '" + downloaded_file + "'")

        return downloaded_file
Exemple #3
0
    def downloadVideo(self, url, title):
        common.log("Trying to download video " + str(url))

        # check url
        if url.startswith("plugin"):
            common.log("Video is not downloadable")
            return None

        path = common.getSetting("download_path")
        if not path:
            path = common.browseFolders(common.translate(30017))
            common.setSetting("download_path", path)

        title = getKeyboard(default=fu.cleanFilename(title), heading="Dragon Streams")
        if title == None or title == "":
            return None

        downloader = Downloader()
        downloaded_file = downloader.downloadMovie(url, path, fu.cleanFilename(title), ".flv")

        if downloaded_file == None:
            common.log("Download cancelled")
        else:
            common.log("Video " + url + " downloaded to '" + downloaded_file + "'")

        return downloaded_file
 def changeLabel(self, item, newLabel):
     found = self._findItem(item)
     if found:
         item['title'] = newLabel
         [cfgFile, data, fav] = found
         # if it's a virtual folder, rename file, rename header, update link
         if self._isVirtualFolder(item):           
             url = item.getInfo('url')
             oldFile = self._getFullPath(url)
             newFilename = urllib.quote_plus(fu.cleanFilename(newLabel))
             virtualFolderFile = newFilename + '.cfg'
             physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
             virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
             # check if new target is valid
             if os.path.exists(virtualFolderPath):
                 prefix = newFilename + '-'
                 suffix = '.cfg'
                 virtualFolderFile = fu.randomFilename(directory=physicalFolder, prefix=prefix, suffix=suffix)
                 virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
             # update header
             content = fu.getFileContent(oldFile)
             oldHeader = self.cfgBuilder.buildHeader(item['title'])
             newHeader = self.cfgBuilder.buildHeader(newLabel)
             content = content.replace(oldHeader, newHeader)
             # rename file
             self._removeVirtualFolder(oldFile, False)
             fu.setFileContent(virtualFolderPath, content)                
             # update link
             item['url'] = self._getShortPath(virtualFolderPath)
         newfav = self._createFavourite(item)
         new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
         fu.setFileContent(cfgFile, new)
    def _addFolder(self, name, rootFolder=None):
        # create cfg
        filename = urllib.quote_plus(fu.cleanFilename(name))
        virtualFolderFile = filename + '.cfg'
        physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
        virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        if os.path.exists(virtualFolderPath):
            prefix = filename + '-'
            suffix = '.cfg'
            virtualFolderFile = fu.randomFilename(directory=physicalFolder, prefix=prefix, suffix=suffix)
            virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        self._createVirtualFolder(name, virtualFolderPath)

        # create link
        linkToFolder = self._createItem(name, 'rss', '', '', None, 'favfolders/' + virtualFolderFile)
        if not rootFolder or os.path.normpath(rootFolder) == self._favouritesFile:
            rootFolder = self._favouritesFile
        fu.appendFileContent(rootFolder, linkToFolder)
        return True
Exemple #6
0
    def _addFolder(self, name, rootFolder=None):
        # create cfg
        filename = urllib.quote_plus(fu.cleanFilename(name))
        virtualFolderFile = filename + '.cfg'
        physicalFolder = os.path.normpath(self._favouritesFoldersFolder)
        virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        if os.path.exists(virtualFolderPath):
            prefix = filename + '-'
            suffix = '.cfg'
            virtualFolderFile = fu.randomFilename(directory=physicalFolder,
                                                  prefix=prefix,
                                                  suffix=suffix)
            virtualFolderPath = os.path.join(physicalFolder, virtualFolderFile)
        self._createVirtualFolder(name, virtualFolderPath)

        # create link
        linkToFolder = self._createItem(name, 'rss', '', '', None,
                                        'favfolders/' + virtualFolderFile)
        if not rootFolder or os.path.normpath(
                rootFolder) == self._favouritesFile:
            rootFolder = self._favouritesFile
        fu.appendFileContent(rootFolder, linkToFolder)
        return True
Exemple #7
0
 def changeLabel(self, item, newLabel):
     found = self._findItem(item)
     if found:
         item['title'] = newLabel
         [cfgFile, data, fav] = found
         # if it's a virtual folder, rename file, rename header, update link
         if self._isVirtualFolder(item):
             url = item.getInfo('url')
             oldFile = self._getFullPath(url)
             newFilename = urllib.quote_plus(fu.cleanFilename(newLabel))
             virtualFolderFile = newFilename + '.cfg'
             physicalFolder = os.path.normpath(
                 self._favouritesFoldersFolder)
             virtualFolderPath = os.path.join(physicalFolder,
                                              virtualFolderFile)
             # check if new target is valid
             if os.path.exists(virtualFolderPath):
                 prefix = newFilename + '-'
                 suffix = '.cfg'
                 virtualFolderFile = fu.randomFilename(
                     directory=physicalFolder, prefix=prefix, suffix=suffix)
                 virtualFolderPath = os.path.join(physicalFolder,
                                                  virtualFolderFile)
             # update header
             content = fu.getFileContent(oldFile)
             oldHeader = self.cfgBuilder.buildHeader(item['title'])
             newHeader = self.cfgBuilder.buildHeader(newLabel)
             content = content.replace(oldHeader, newHeader)
             # rename file
             self._removeVirtualFolder(oldFile, False)
             fu.setFileContent(virtualFolderPath, content)
             # update link
             item['url'] = self._getShortPath(virtualFolderPath)
         newfav = self._createFavourite(item)
         new = data.replace(fav, enc.smart_unicode(newfav).encode('utf-8'))
         fu.setFileContent(cfgFile, new)