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


Python CURLLoader类代码示例

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


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

示例1: play

    def play(self, playlist, first, last):
        self.pls.clear()

        if first == last:
            URL = playlist.list[first].URL
            xbmc.Player.play(self, URL)
        else:
        
            index = first
            urlopener = CURLLoader()
            self.stopped=False
            while index <= last and self.stopped == False and self.pls.size() < 100:                
                type = playlist.list[index].type
                if type == 'video' or type == 'audio':
                    URL = playlist.list[index].URL

                    result = urlopener.urlopen(URL)
                    if result == 0:
                        loc_url = urlopener.loc_url

                        name = playlist.list[index].name
                        self.pls.add(loc_url, name)
                        
                        if self.pls.size() == 1:
                            #start playing                        
                            xbmc.Player.play(self, self.pls)
                index = index + 1
            
            if self.pls.size() == 0:
                #no valid items found
                return -1
                
        return 0
开发者ID:Bram77,项目名称:xbmc-favorites,代码行数:33,代码来源:CPlayer.py

示例2: InstallSkin

    def InstallSkin(self, URL='', mediaitem=CMediaItem()):
        if URL != '':
            self.URL = URL
        else:
            self.URL = mediaitem.URL
        
        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result == 0:
            self.URL = urlopener.loc_url
        
        SetInfoText("Downloading... ")
        
        #download the file.
        loader = CFileLoader2()
        loader.load(self.URL, tempCacheDir + 'skin.zip')
        if loader.state != 0:
            return -2
        filename = loader.localfile

        SetInfoText("Installing... ")

        result = self.unzip_file_into_dir(filename, skinDir)   

        return result
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:25,代码来源:CInstaller.py

示例3: get_real_url

    def get_real_url(self, entry, header=""):
        self.state = 0 #success

        URL = entry.URL
        localfile = entry.DLloc

        #download of FTP file is handled in a separte function
        if URL[:3] == 'ftp':
            self.download_fileFTP(entry, header)
            return "ftp"

        if URL[:4] != 'http':
            self.state = -1 #URL does not point to internet file.
            return "non http"

        #Continue with HTTP download
        #self.MainWindow.dlinfotekst.setLabel('(' + header + ')' + " Retrieving file info...")
        #entry.processed=self.processed

        # set custom headers if specified
        URL, headers=parse_headers(URL, entry)

        #Get the direct URL to the mediaitem given URL 
        urlopener = CURLLoader()
        result = urlopener.urlopen(URL, entry)
        if result["code"] != 0:
            self.state = -1 #failed to download the file
            print "urlopener.urlopen failed"
            return "urlopen failed"

        URL = urlopener.loc_url

	return URL
开发者ID:NavFRi-x,项目名称:Navi-X-FR,代码行数:33,代码来源:CDownLoader.py

示例4: InstallScript

    def InstallScript(self, URL='', mediaitem=CMediaItem()):
        if URL != '':
            self.URL = URL
        else:
            self.URL = mediaitem.URL
        
        dialog=xbmcgui.DialogProgress()
        dialog.create("Installer")
        dialog.update(33,"Downloading file...")
        
        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result == 0:
            self.URL = urlopener.loc_url
               
        #download the file.
        loader = CFileLoader()
        loader.load(self.URL, cacheDir + 'script.zip')
        if loader.state != 0:
            return -2
        filename = loader.localfile

        dialog.update(66,"Installing...")

        result = self.unzip_file_into_dir(filename, scriptDir)   

        dialog.close()

        return result
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:29,代码来源:CInstaller.py

示例5: InstallScript

    def InstallScript(self, URL="", mediaitem=CMediaItem()):
        if URL != "":
            self.URL = URL
        else:
            self.URL = mediaitem.URL

        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result["code"] == 0:
            self.URL = urlopener.loc_url

        SetInfoText("Downloading... ", setlock=True)

        # download the file.
        loader = CFileLoader2()
        loader.load(self.URL, tempCacheDir + "script.zip")
        if loader.state != 0:
            return -2
        filename = loader.localfile

        SetInfoText("Installing... ", setlock=True)

        result = self.unzip_file_into_dir(filename, scriptDir)

        return result
开发者ID:Stevie-Bs,项目名称:navi-x,代码行数:25,代码来源:CInstaller.py

示例6: InstallPlugin

    def InstallPlugin(self, URL="", mediaitem=CMediaItem()):
        if URL != "":
            self.URL = URL
        else:
            self.URL = mediaitem.URL

        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result["code"] == 0:
            self.URL = urlopener.loc_url

        # retrieve the type of plugin
        index = mediaitem.type.find(":")
        if index != -1:
            subdir = mediaitem.type[index + 1 :] + "\\"
        else:
            subdir = ""

        SetInfoText("Downloading... ", setlock=True)

        # download the file.
        loader = CFileLoader2()
        loader.load(self.URL, tempCacheDir + "plugin.zip", content_type="zip")
        if loader.state != 0:
            if loader.state == -2:
                dialog = xbmcgui.Dialog()
                dialog.ok(" Installer", "Failed. Not a ZIP file.", "Use the standard Download feature.")
            return -2
        filename = loader.localfile

        SetInfoText("Installing... ", setlock=True)

        result = self.unzip_file_into_dir(filename, pluginDir + subdir)

        return result
开发者ID:Stevie-Bs,项目名称:navi-x,代码行数:35,代码来源:CInstaller.py

示例7: play_URL

    def play_URL(self, URL, mediaitem=0):
        #URL=mediaitem.URL
        #check if the URL is empty or not
        if URL == '':
            return -1
                                              
        urlopener = CURLLoader()
        result = urlopener.urlopen(URL, mediaitem)
        if result != 0:
            return -1    
        URL = urlopener.loc_url
        
        SetInfoText("Loading... ")

        self.pls.clear() #clear the playlist
    
        ext = getFileExtension(URL)
        if ext == 'pls' or ext == 'm3u':
            loader = CFileLoader2() #file loader
            loader.load(URL, tempCacheDir + "playlist." + ext, retries=2)
            if loader.state == 0: #success
                result = self.pls.load(loader.localfile)
                if result == False:
                    return -1
                xbmc.Player.play(self, self.pls) #play the playlist
        else:
            #self.pls.add(urlopener.loc_url)
            if mediaitem.playpath != '':
                self.play_RTMP(mediaitem.URL, mediaitem.playpath, mediaitem.swfplayer, mediaitem.pageurl);
            else:  
                xbmc.Player.play(self, urlopener.loc_url)
            
        return 0
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:33,代码来源:CPlayer.py

示例8: read_file_info

    def read_file_info(self, entry):
        self.state = 0  # success
        ext = ""  # no extension
        size = 0

        URL = entry.URL

        if URL[:3] == "ftp":
            # FTP
            ext = getFileExtension(URL)
            if ext != "":
                ext = "." + ext
        else:
            # HTTP
            urlopener = CURLLoader()
            result = urlopener.urlopen(URL, entry)
            if result != 0:
                self.state = -1  # URL does not point to internet file.
                return
            loc_url = urlopener.loc_url

            # Now we try to open the URL. If it does not exist an error is
            # returned.
            try:
                headers = {"User-Agent": "Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)"}
                req = urllib2.Request(loc_url, None, headers)
                f = urllib2.urlopen(req)
                # loc_url=f.geturl()
                size_string = f.headers["Content-Length"]
                size = int(size_string)
                f.close()
            except:
                size = 0

            # special handing for some URL's
            pos = URL.find("http://www.youtube.com")  # find last 'http' in the URL
            if pos != -1:
                ext = ".mp4"
            else:
                # todo: deprecated
                pos = URL.find("flyupload.com")
                if pos != -1:
                    ext = ".avi"
                else:
                    # extract the file extension
                    url_stripped = re.sub("\?.*$", "", loc_url)  # strip GET-method args
                    re_ext = re.compile("(\.\w+)$")  # find extension
                    match = re_ext.search(url_stripped)
                    if match is None:
                        # ext = ""
                        ext = getFileExtension(loc_url)
                        if ext != "":
                            ext = "." + ext
                    else:
                        ext = match.group(1)

        return ext, size
开发者ID:tderuvo,项目名称:Gogo-TV-Plus,代码行数:57,代码来源:CDownLoader.py

示例9: read_file_info

    def read_file_info(self, entry):
        self.state = 0 #success    
        ext='' #no extension
    
        URL = entry.URL
    
        if URL[:3] == 'ftp':
            #FTP
            ext = getFileExtension(URL)
            if ext != '':
                ext = '.' + ext
        else:
            #HTTP
            urlopener = CURLLoader()
            result = urlopener.urlopen(URL, entry)
            if result != 0:
                self.state = -1 #URL does not point to internet file.
                return
            loc_url = urlopener.loc_url

            #Now we try to open the URL. If it does not exist an error is
            #returned.
            try:
                headers = { 'User-Agent' : 'Mozilla/4.0 (compatible;MSIE 7.0;Windows NT 6.0)'}
                req = urllib2.Request(loc_url, None, headers)
                f = urllib2.urlopen(req)
                loc_url=f.geturl()
                size_string = f.headers['Content-Length']
                size = int(size_string)

            except IOError:
                self.state = -1 #failed to open the HTTP URL
                return
            
            #special handing for some URL's
            pos = URL.find('http://www.youtube.com') #find last 'http' in the URL
            if pos != -1:
                ext='.mp4'
            else:
#todo: deprecated            
                pos = URL.find("flyupload.com")
                if pos != -1:
                    ext='.avi'
                else:
                    #extract the file extension
                    url_stripped = re.sub('\?.*$', '', loc_url) # strip GET-method args
                    re_ext = re.compile('(\.\w+)$') # find extension
                    match = re_ext.search(url_stripped)
                    if match is None:
                        ext = ""
                    else:
                        ext = match.group(1)

        return ext, size
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:54,代码来源:CDownLoader.py

示例10: play

    def play(self, playlist, first, last):
        self.pls.clear()

        if first == last:
            URL = playlist.list[first].URL
            xbmc.Player.play(self, URL)
        else:
        
            index = first
            urlopener = CURLLoader()
            self.stopped=False
            count=0
            while (index <= last) and (self.stopped == False):        
                if (count>0) and not (xbmc.Player().isPlaying()):
                    self.stopped=True
                type = playlist.list[index].type
                if type == 'video' or type == 'audio' or type == 'ps3plus':
                    URL = playlist.list[index].URL

                    result = urlopener.urlopen(URL, playlist.list[index])
                    if result["code"] == 0:
                        loc_url = urlopener.loc_url

                        name = playlist.list[index].name
                        
                        #if (xbmc.getInfoLabel("System.BuildVersion")[:1] == '9') or \
                        #   (xbmc.getInfoLabel("System.BuildVersion")[:2] == '10'):                        
                        listitem = xbmcgui.ListItem(name)
                        listitem.setInfo('video', {'Title': name})
                        self.pls.add(url=loc_url, listitem=listitem)                      
                        #else:
                        #    self.pls.add(loc_url, name)
                        
                        if self.pls.size() == 1:
                            #start playing, continue loading                      
                            xbmc.Player.play(self, self.pls)
                index = index + 1
                count = count + 1
            
            if self.pls.size() == 0:
                #no valid items found
                return {"code":1,"data":"no valid items found"}
        
        if not (xbmc.Player().isPlaying()):
            return {"code":1,"data":"no valid items found"} 

        return {"code":0}
开发者ID:pmietlicki,项目名称:kodi-repo,代码行数:47,代码来源:CPlayer.py

示例11: InstallApiPortail

    def InstallApiPortail(self, URL='', mediaitem=CMediaItem()):
        if URL != '':
            self.URL = URL
        else:
            self.URL = mediaitem.URL
        
        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result["code"] == 0:
            self.URL = urlopener.loc_url
        
        SetInfoText("Telechargement... ", setlock=True)
        
        #download the file.
        loader = CFileLoader2()
        loader.load(self.URL, tempCacheDir + 'script.zip')
        if loader.state != 0:
            return -2
        filename = loader.localfile

        SetInfoText("Installing... ", setlock=True)

        #determine the install dir based on the current directory (root)
        if RootDir[0] == '/':
            pos =   RootDir.rfind("/",0,-1)
        else:
            pos =   RootDir.rfind("\\",0,-1)
            
        if pos != -1:
            InstallDir = RootDir[0:pos+1]

            print "Installation aPiPortail dans: " + InstallDir

            result = self.unzip_file_into_dir(filename, InstallDir)
            
            if result == 0: #remove pyo files (needed for XBMC Dharma)
                self.delPYOFiles(RootDir+'src')
            
        else:
            result = -1
        
        return result
开发者ID:pmietlicki,项目名称:kodi-repo,代码行数:42,代码来源:CInstaller.py

示例12: InstallNaviX

    def InstallNaviX(self, URL="", mediaitem=CMediaItem()):
        if URL != "":
            self.URL = URL
        else:
            self.URL = mediaitem.URL

        urlopener = CURLLoader()
        result = urlopener.urlopen(self.URL, mediaitem)
        if result["code"] == 0:
            self.URL = urlopener.loc_url

        SetInfoText("Downloading... ", setlock=True)

        # download the file.
        loader = CFileLoader2()
        loader.load(self.URL, tempCacheDir + "script.zip")
        if loader.state != 0:
            return -2
        filename = loader.localfile

        SetInfoText("Installing... ", setlock=True)

        # determine the install dir based on the current Navi-X directory (root)
        if RootDir[0] == "/":
            pos = RootDir.rfind("/", 0, -1)
        else:
            pos = RootDir.rfind("\\", 0, -1)

        if pos != -1:
            InstallDir = RootDir[0 : pos + 1]

            print "Installing Navi-X in: " + InstallDir

            result = self.unzip_file_into_dir(filename, InstallDir)

            if result == 0:  # remove pyo files (needed for XBMC Dharma)
                self.delPYOFiles(RootDir + "src")

        else:
            result = -1

        return result
开发者ID:Stevie-Bs,项目名称:navi-x,代码行数:42,代码来源:CInstaller.py

示例13: play

    def play(self, playlist, first, last):
        self.pls.clear()

        if first == last:
            URL = playlist.list[first].URL
            self.Attempt_to_play_URL(URL)
            # xbmc.Player.play(self, URL)
        else:

            index = first
            urlopener = CURLLoader()
            self.stopped = False
            while (index <= last) and (self.stopped == False) and (self.pls.size() < 10):
                type = playlist.list[index].type
                if type == "video" or type == "audio":
                    URL = playlist.list[index].URL

                    result = urlopener.urlopen(URL, playlist.list[index])
                    if result["code"] == 0:
                        loc_url = urlopener.loc_url

                        name = playlist.list[index].name

                        # if (xbmc.getInfoLabel("System.BuildVersion")[:1] == '9') or \
                        #   (xbmc.getInfoLabel("System.BuildVersion")[:2] == '10'):
                        listitem = xbmcgui.ListItem(name)
                        listitem.setInfo("video", {"Title": name})
                        self.pls.add(url=loc_url, listitem=listitem)
                        # else:
                        #    self.pls.add(loc_url, name)

                        if self.pls.size() == 1:
                            # start playing, continue loading
                            self.Attempt_to_play_URL(URL)
                            # xbmc.Player.play(self, self.pls)
                index = index + 1

            if self.pls.size() == 0:
                # no valid items found
                return {"code": 1, "data": "no valid items found"}

        return {"code": 0}
开发者ID:bialagary,项目名称:mw,代码行数:42,代码来源:CPlayer.py

示例14: InstallPlugin

 def InstallPlugin(self, URL='', mediaitem=CMediaItem()):            
     if URL != '':
         self.URL = URL
     else:
         self.URL = mediaitem.URL
     
     dialog=xbmcgui.DialogProgress()
     dialog.create("Installer")
     dialog.update(33,"Downloading file...")        
     
     urlopener = CURLLoader()
     result = urlopener.urlopen(self.URL, mediaitem)
     if result == 0:
         self.URL = urlopener.loc_url
     
     
     #retrieve the type of plugin
     index=mediaitem.type.find(":")
     if index != -1:
         subdir = mediaitem.type[index+1:] + '\\'
     else:
         subdir = ''
            
     #download the file.
     loader = CFileLoader()
     loader.load(self.URL, cacheDir + 'plugin.zip', content_type='zip')
     if loader.state != 0:
         if loader.state == -2:
             dialog = xbmcgui.Dialog()
             dialog.ok(" Installer", "Failed. Not a ZIP file.", "Use the standard Download feature.")
         return -2
     filename = loader.localfile
     
     dialog.update(66,"Installing...")
     
     result = self.unzip_file_into_dir(filename, pluginDir + subdir)    
    
     dialog.close()
    
     return result
开发者ID:drrlramsey,项目名称:xbmc-addons,代码行数:40,代码来源:CInstaller.py

示例15: play_URL

    def play_URL(self, URL, mediaitem=0):
        #URL=mediaitem.URL
        #check if the URL is empty or not
        if URL == '':
            return {"code":1, "data":"URL is empty"}
                                              
        urlopener = CURLLoader()
        result = urlopener.urlopen(URL, mediaitem)
        if result["code"] != 0:
            return result   
        URL = urlopener.loc_url
        
        SetInfoText("Loading...... ", setlock=True)

        self.pls.clear() #clear the playlist
                
        ext = getFileExtension(URL)
#todo ashx  
        if ext == 'ashx':
            ext = 'm3u'
               
        if ext == 'pls' or ext == 'm3u':
            loader = CFileLoader2() #file loader
            loader.load(URL, tempCacheDir + "playlist." + ext, retries=2)
            if loader.state == 0: #success
                result = self.pls.load(loader.localfile)
                if result == False:
                    return {"code":1}
                    
                #xbmc.Player.play(self, self.pls) #play the playlist
                self.play_media(loader.localfile)
        else:
            #self.pls.add(urlopener.loc_url)
            if mediaitem.playpath != '':
                self.play_RTMP(mediaitem.URL, mediaitem.playpath, mediaitem.swfplayer, mediaitem.pageurl);
            else: 
                self.play_media(URL)
            
        return {"code":0}
开发者ID:Gemini88,项目名称:addons,代码行数:39,代码来源:CPlayer.py


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