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


Python urllib.quote_plus方法代码示例

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


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

示例1: play

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def play(url, id=0):
	print url
	engine=__settings__.getSetting("Engine")
	if engine=="0":
		play_ace(url, id)
		
	if engine=="1":
		item = xbmcgui.ListItem()#path=url
		xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
		tthp.play(url, handle, id, __settings__.getSetting("DownloadDirectory"))
		
	if engine=="2":
		purl ="plugin://plugin.video.yatp/?action=play&torrent="+ urllib.quote_plus(url)+"&file_index="+str(id)
		item = xbmcgui.ListItem()#path=purl
		xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
		xbmc.Player().play(purl) 
开发者ID:tdw1980,项目名称:tdw,代码行数:18,代码来源:default.py

示例2: add_item

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def add_item (name, mode="", path = Pdir, ind="0", cover=None, funart=None):
	#print name
	#print path
	if   path.find("720p")>0: qual="[COLOR FFA900EF][ 720p ] [/COLOR]"
	elif path.find("480p")>0: qual="[COLOR FFFF0090][ 480p ] [/COLOR]"
	elif path.find("400p")>0: qual="[COLOR FF70F020][ 400p ] [/COLOR]"
	elif path.find("1080p")>0:qual="[COLOR FF50FF50][1080p] [/COLOR]"
	else: qual="[ ???? ] "
	if cover==None:	listitem = xbmcgui.ListItem(qual+"[B]"+name+"[/B]")
	else:			listitem = xbmcgui.ListItem(qual+"[B]"+name+"[/B]", iconImage=cover)
	listitem.setProperty('fanart_image', funart)
	uri = sys.argv[0] + '?mode='+mode
	uri += '&url='  + urllib.quote_plus(path.encode('utf-8'))
	uri += '&name='  + urllib.quote_plus(xt(name))
	uri += '&ind='  + urllib.quote_plus(ind)
	if cover!=None:uri += '&cover='  + urllib.quote_plus(cover)
	if funart!=None and funart!="":uri += '&funart='  + urllib.quote_plus(funart)
	
	if mode=="play": fld=False
	else: fld=True

	xbmcplugin.addDirectoryItem(handle, uri, listitem, fld) 
开发者ID:tdw1980,项目名称:tdw,代码行数:24,代码来源:default.py

示例3: _make_path

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def _make_path(self, items):
        '''Returns a relative path for the given dictionary of items.

        Uses this url rule's url pattern and replaces instances of <var_name>
        with the appropriate value from the items dict.
        '''
        for key, val in items.items():
            if not isinstance(val, basestring):
                raise TypeError, ('Value "%s" for key "%s" must be an instance'
                                  ' of basestring' % (val, key))
            items[key] = quote_plus((val).encode('utf-8'))

        try:
            path = self._url_format.format(**items)
        except AttributeError:
            # Old version of python
            path = self._url_format
            for key, val in items.items():
                path = path.replace('{%s}' % key, val)
        return path 
开发者ID:jmarth,项目名称:plugin.video.kmediatorrent,代码行数:22,代码来源:urls.py

示例4: unzip

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def unzip(path, dest, folder=None):

    ''' Unzip file. zipfile module seems to fail on android with badziperror.
    '''
    path = urllib.quote_plus(path)
    root = "zip://" + path + '/'
    
    if folder:

        xbmcvfs.mkdir(os.path.join(dest, folder))
        dest = os.path.join(dest, folder)
        root = get_zip_directory(root, folder)

    dirs, files = xbmcvfs.listdir(root)

    if dirs:
        unzip_recursive(root, dirs, dest)

    for file in files:
        unzip_file(os.path.join(root, file.decode('utf-8')), os.path.join(dest, file.decode('utf-8')))

    LOG.warn("Unzipped %s", path) 
开发者ID:MediaBrowser,项目名称:plugin.video.emby,代码行数:24,代码来源:utils.py

示例5: do_command

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def do_command(self, verb, args):
        conn = httplib.HTTPConnection(self.host, self.port)
        body = u'cmd=' + urllib.quote_plus(unicode(verb).encode('utf-8'))
        for i in range(len(args)):
            body += '&' + unicode(i+1) + '=' + urllib.quote_plus(unicode(args[i]).encode('utf-8'))
        if (None != self.sessionId):
            body += "&sessionId=" + unicode(self.sessionId)
        headers = {"Content-Type": "application/x-www-form-urlencoded; charset=utf-8"}
        conn.request("POST", "/selenium-server/driver/", body, headers)
    
        response = conn.getresponse()
        #print response.status, response.reason
        data = unicode(response.read(), "UTF-8")
        result = response.reason
        #print "Selenium Result: " + repr(data) + "\n\n"
        if (not data.startswith('OK')):
            raise Exception, data
        return data 
开发者ID:elsigh,项目名称:browserscope,代码行数:20,代码来源:selenium.py

示例6: add_videos

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def add_videos(episode_tree, SITE):
	episodes = []
	episode_menu = episode_tree.find_all('div', class_ = 'media-module')
	show_name = episode_tree.find('h1').text
	for episode_item in episode_menu:
		episode_name = episode_item.a['data-title']
		episode_thumb = urllib.unquote_plus(episode_item.a.img['data-src'].split('url=')[1])
		try:
			episode_duration = common.format_seconds(episode_item.find('div', class_='timestamp').text.strip())
		except:
			episode_duration = -1
		url = episode_item.a['href']
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'durationinseconds' : episode_duration,
						'TVShowTitle' : show_name }
		episodes.append((u, episode_name, episode_thumb, infoLabels, 'list_qualities', False, 'Full Episode'))
	return episodes 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:23,代码来源:main_natgeo.py

示例7: add_videos

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def add_videos(episode_tree):
	episodes = []
	episode_menu = episode_tree.find_all('li', recursive = False)
	for episode_item in episode_menu:
		try:
			show_name = common.args.name
		except:
			show_name = None
		episode_link = episode_item.h4.a
		episode_name = episode_link.text
		url = BASE + episode_link['href']
		episode_thumb = episode_item.find('img')['src'].split('?')[0]
		episode_plot = episode_item.find('p', class_ = 'description').text
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(url) + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels = {	'title' : episode_name,
						'plot' : episode_plot,
						'tvshowtitle' : show_name }
		episodes.append((u, episode_name, episode_thumb, infoLabels, 'list_qualities', False, 'Full Episode'))
	return episodes 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:24,代码来源:nickteen.py

示例8: seasons

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def seasons(season_url = common.args.url):
	seasons = []
	if season_url in different_show_name:
		season_url = different_show_name[season_url]
	season_data = connection.getURL(FULLEPISODES % urllib.quote_plus(season_url) + '&range=0-1')
	try:
		season_menu = int(simplejson.loads(season_data)['total_count'])
	except:
		season_menu = 0
	if season_menu > 0:
		season_url2 = FULLEPISODES % urllib.quote_plus(season_url) + '&range=0-' + str(season_menu)
		seasons.append(('Full Episodes',  SITE, 'episodes', season_url2, -1, -1))
	season_data2 = connection.getURL(CLIPS % urllib.quote_plus(season_url) + '&range=0-1')
	try:
		season_menu2 = int(simplejson.loads(season_data2)['total_count'])
	except:
		season_menu2 = 0
	if season_menu2 > 0:
		season_url3 = CLIPS % urllib.quote_plus(season_url) + '&range=0-' + str(season_menu2)
		seasons.append(('Clips',  SITE, 'episodes', season_url3, -1, -1))
	return seasons 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:23,代码来源:fox.py

示例9: episodes

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def episodes(episode_url = common.args.url):
	episodes = []
	episode_data = connection.getURL(SHOWS)
	episode_tree = BeautifulSoup(episode_data, 'html.parser')
	episode_carousel = episode_tree.find('h2', text = re.compile(episode_url)).parent.parent
	for episode_item in episode_carousel.find_all('span', class_ = 'col'):
		try:
			episode_name = re.compile('"(.*)"').findall(episode_item.h3.string)[0]
		except:
			episode_name = episode_item.h3.string
		print episode_name
		episode_thumb = episode_item.img['src']
		try:
			episode_url = episode_item.a['href']
		except:
			episode_url = ''
		url = episode_url
		u = sys.argv[0]
		u += '?url="' + urllib.quote_plus(episode_url)  + '"'
		u += '&mode="' + SITE + '"'
		u += '&sitemode="play_video"'
		infoLabels={'title' : episode_name }
		episodes.append((u, episode_name, episode_thumb, infoLabels, None, False, 'Clip'))
	return episodes 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:26,代码来源:marvelkids.py

示例10: episodes

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def episodes(episode_url = common.args.url):
	episodes = []
	episode_data = connection.getURL(EPISODES + episode_url)
	episode_data2 = simplejson.loads(episode_data)['list_html']
	episode_tree = BeautifulSoup(episode_data2, 'html.parser').find('ul', id = 'videoList_ul')
	if episode_tree:
		episode_menu = episode_tree.find_all('li', recursive = False)
		for episode_item in episode_menu:
			infoLabels={}
			url = episode_item['id'][6:]
			episode_thumb = episode_item.img['src'].replace('103x69', '640x480')
			episode_name = episode_item.span.string
			episode_plot = episode_item.find(id = 'viddesc_' + url).string
			show_name = episode_item.find(id = 'vidtitle_' + url).string
			u = sys.argv[0]
			u += '?url="' + urllib.quote_plus(url) + '"'
			u += '&mode="' + SITE + '"'
			u += '&sitemode="play_video"'
			infoLabels={	'title' : episode_name,
							'plot' : episode_plot,
							'TVShowTitle' : show_name }
			episodes.append((u, episode_name, episode_thumb, infoLabels, None, False, 'Clip'))
	return episodes 
开发者ID:moneymaker365,项目名称:plugin.video.ustvvod,代码行数:25,代码来源:thewbkids.py

示例11: list_request_by_did

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def list_request_by_did(self, name, rse, scope=None):
        """Return latest request details for a DID

        :param name: DID
        :type name: str
        :param rse: Destination RSE name
        :type rse: str
        :param scope: rucio scope, defaults to None
        :param scope: str, optional
        :raises exc_cls: from BaseClient._get_exception
        :return: request information
        :rtype: dict
        """

        path = '/'.join(['requests', quote_plus(scope), quote_plus(name), rse])
        url = build_url(choice(self.list_hosts), path=path)
        r = self._send_request(url, type='GET')

        if r.status_code == codes.ok:
            return next(self._load_json_data(r))
        else:
            exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
            raise exc_cls(exc_msg) 
开发者ID:rucio,项目名称:rucio,代码行数:25,代码来源:requestclient.py

示例12: add_scope

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def add_scope(self, account, scope):
        """
        Sends the request to add a new scope.

        :param account: the name of the account to add the scope to.
        :param scope: the name of the new scope.
        :return: True if scope was created successfully.
        :raises Duplicate: if scope already exists.
        :raises AccountNotFound: if account doesn't exist.
        """

        path = '/'.join([self.SCOPE_BASEURL, account, 'scopes', quote_plus(scope)])
        url = build_url(choice(self.list_hosts), path=path)
        r = self._send_request(url, type='POST')
        if r.status_code == codes.created:
            return True
        else:
            exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
            raise exc_cls(exc_msg) 
开发者ID:rucio,项目名称:rucio,代码行数:21,代码来源:scopeclient.py

示例13: list_file_replicas

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def list_file_replicas(self, scope, lfn):
        """
        List file replicas.

        :param scope: the scope.
        :param lfn: the lfn.

        :return: List of replicas.
        """
        path = '/'.join([self.BASEURL, quote_plus(scope), quote_plus(lfn), 'rses'])
        url = build_url(choice(self.list_hosts), path=path)

        r = self._send_request(url, type='GET')

        if r.status_code == codes.ok:
            rses = loads(r.text)
            return rses
        else:
            print(r.status_code)
            exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
            raise exc_cls(exc_msg) 
开发者ID:rucio,项目名称:rucio,代码行数:23,代码来源:fileclient.py

示例14: list_dataset_replicas

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def list_dataset_replicas(self, scope, name, deep=False):
        """
        List dataset replicas for a did (scope:name).

        :param scope: The scope of the dataset.
        :param name: The name of the dataset.
        :param deep: Lookup at the file level.

        :returns: A list of dict dataset replicas.

        """
        payload = {}
        if deep:
            payload = {'deep': True}

        url = build_url(self.host,
                        path='/'.join([self.REPLICAS_BASEURL, quote_plus(scope), quote_plus(name), 'datasets']),
                        params=payload)
        r = self._send_request(url, type='GET')
        if r.status_code == codes.ok:
            return self._load_json_data(r)
        exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
        raise exc_cls(exc_msg) 
开发者ID:rucio,项目名称:rucio,代码行数:25,代码来源:replicaclient.py

示例15: list_dataset_replicas_vp

# 需要导入模块: import urllib [as 别名]
# 或者: from urllib import quote_plus [as 别名]
def list_dataset_replicas_vp(self, scope, name, deep=False):
        """
        List dataset replicas for a DID (scope:name) using the
        Virtual Placement service.

        NOTICE: This is an RnD function and might change or go away at any time.

        :param scope: The scope of the dataset.
        :param name: The name of the dataset.
        :param deep: Lookup at the file level.

        :returns: If VP exists a list of dicts of sites
        """
        payload = {}
        if deep:
            payload = {'deep': True}

        url = build_url(self.host,
                        path='/'.join([self.REPLICAS_BASEURL, quote_plus(scope), quote_plus(name), 'datasets_vp']),
                        params=payload)
        r = self._send_request(url, type='GET')
        if r.status_code == codes.ok:
            return self._load_json_data(r)
        exc_cls, exc_msg = self._get_exception(headers=r.headers, status_code=r.status_code, data=r.content)
        raise exc_cls(exc_msg) 
开发者ID:rucio,项目名称:rucio,代码行数:27,代码来源:replicaclient.py


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