当前位置: 首页>>代码示例>>Python>>正文


Python CURLLoader.geturl_processor方法代码示例

本文整理汇总了Python中CURLLoader.geturl_processor方法的典型用法代码示例。如果您正苦于以下问题:Python CURLLoader.geturl_processor方法的具体用法?Python CURLLoader.geturl_processor怎么用?Python CURLLoader.geturl_processor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CURLLoader的用法示例。


在下文中一共展示了CURLLoader.geturl_processor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: browse

# 需要导入模块: import CURLLoader [as 别名]
# 或者: from CURLLoader import geturl_processor [as 别名]
    def browse(self, entry, dir=myDownloadsDir):
        self.state = 0 #success
        self.dir = ''
        self.processed=False
       
        URL=entry.URL

        if (URL[:4] != 'http') and (URL[:3] != 'ftp'):
            self.state = -1 #URL does not point to internet file.
            return

        if re.search('^http://(\w+\.)?(icefilms|mega(upload|video))\.', URL):
            size_check_skip=True
        else:
            size_check_skip=False
            
        if size_check_skip:
            print("Mega URL; skipping size check")
            size=0
            urlopener = CURLLoader()
            result = urlopener.geturl_processor(entry)
            URL=entry.URL
            loc_url=URL
            self.processed=entry.processed          
            self.loc_url=URL
            url_stripped = re.sub('\?.*$', '', loc_url) # strip GET-method args
            url_stripped = re.sub('\|.*$', '', url_stripped) # strip header info if any
            # find extension
            match = re.search('(\.\w+)$',url_stripped)
            if match is None:
                #ext = ""
                ext = getFileExtension(loc_url)
                if ext != '':
                    ext = '.' + ext
            else:
                ext = match.group(1)
        else:
            ext, size = self.read_file_info(entry)
            url_stripped = re.sub('\?.*$', '', entry.URL) # strip GET-method args
            url_stripped = re.sub('\&.*$', '', entry.URL) # strip odd GET-method args
            url_stripped = re.sub('\|.*$', '', url_stripped) # strip header info if any

        if self.state != 0:
            return
               
        # For the local file name we use the playlist item 'name' field.
        # But this string may contain invalid characters. Therefore
        # we strip these invalid characters. We also limit the file
        # name length to 42 which is the XBMC XBOX limit.

        if re.search('^Source #', entry.name):
            localfile=url_stripped[url_stripped.rindex("/")+1:]
        else:
            localfile = re.sub('[^\w\s-]', '', entry.name) # remove characters which are not a letter, digit, white-space, underscore, or dash
            localfile = re.sub('\s+', ' ', localfile) # convert all instances of multiple spaces to single spaces
            localfile = localfile[:(42-len(ext))] # limit to 42 characters.
            localfile = localfile + ext
        
        if size_check_skip:
            heading="Download File"
        else:
            size_string, raw_size = self.file_size(size,'')
            heading = "Download File: (Size = %s)" % size_string
            
        if (entry.type=='playlist') and (localfile.lower().endswith('.plx')==False):
            localfile+='.plx'
        
        #browsewnd = CDialogBrowse("CBrowseskin.xml", os.getcwd())
        curdir = addon.getAddonInfo('path')
        browsewnd = CDialogBrowse("CBrowseskin2.xml", curdir)
        browsewnd.SetFile(dir, localfile, 3, heading)
        browsewnd.doModal()

        if browsewnd.state != 0:
            self.state = -2 #cancel download
            return
        
        self.localfile = browsewnd.dir + browsewnd.filename
        self.dir = browsewnd.dir
        
        #Check if the file already exists
        if os.path.exists(self.localfile):
            dialog = xbmcgui.Dialog()
            if dialog.yesno("Message", "The destination file already exists, continue?") == False:
                self.state = -2 #cancel download
开发者ID:bialagary,项目名称:mw,代码行数:87,代码来源:CDownLoader.py


注:本文中的CURLLoader.geturl_processor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。