本文整理汇总了Python中pyamf.remoting.client.RemotingService.addHTTPHeader方法的典型用法代码示例。如果您正苦于以下问题:Python RemotingService.addHTTPHeader方法的具体用法?Python RemotingService.addHTTPHeader怎么用?Python RemotingService.addHTTPHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyamf.remoting.client.RemotingService
的用法示例。
在下文中一共展示了RemotingService.addHTTPHeader方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _resolve_rtmp_playback_url_via_flash
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def _resolve_rtmp_playback_url_via_flash(self, key):
self._addon.log_notice("Resolving rtmp playback url for %s using flash" % key)
user_agent = getUserAgent()
self._addon.log_notice("Using user agent '%s'" % user_agent)
svc = RemotingService(self._AMF_ENDPOINT, amf_version = 0, user_agent = user_agent)
svc.addHTTPHeader('Cookie', 'r=' + self._state['rdio_cookie'])
svc.addHTTPHeader('Host', 'www.rdio.com')
rdio_svc = svc.getService('rdio')
playback_token = self._state['playback_token']
secret_string = key + playback_token + self._RDIO_PLAYBACK_SECRET
secret = self._RDIO_PLAYBACK_SECRET_SEED
for c in secret_string:
secret = ((secret << 5) + secret + ord(c)) % 65536;
playerName = 'api_%s' % str(int(math.floor(random.random() * 1000000)))
pi = rdio_svc.getPlaybackInfo({
'domain': self._RDIO_DOMAIN,
'playbackToken': playback_token,
'manualPlay': False,
'requiresUnlimited': False,
'playerName': playerName,
'type': 'flash',
'secret': secret,
'key': key})
if not pi:
raise Exception, 'Failed to get playback info'
return self._extract_rtmp_url_from_playback_info(pi)
示例2: findMediaById
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def findMediaById(self, playerId, videoPlayer, publisherId, userAgent, amfVersion = pyamf.AMF3, **kwargs):
client = RemotingService(self._amfUrl, user_agent = userAgent, amf_version = amfVersion)
for k, v in kwargs.iteritems():
if k == 'headers':
for header in v:
client.addHTTPHeader(header[0], header[1])
if k == 'proxy':
client.setProxy(v)
service = client.getService(self._serviceName)
return service.findMediaById(self._token, playerId, videoPlayer, publisherId)
示例3: getBrightCoveData
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def getBrightCoveData(self, playerId, userAgent, amfVersion = pyamf.AMF3, **kwargs):
client = RemotingService(self._amfUrl, user_agent = userAgent, amf_version = amfVersion)
for k, v in kwargs.iteritems():
if k == 'headers':
for header in v:
client.addHTTPHeader(header[0], header[1])
if k == 'proxy':
client.setProxy(v)
service = client.getService(self._serviceName)
return service.getProgrammingForExperience(self._token, playerId)
示例4: getServices
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def getServices(self):
'''get game services'''
client = RemotingService('http://xiaonei.paopaoyu.cn/gateway/')
client.amf_version=0
client.client_type=3
client.strict=True
client.request_number=self.id
self.id+=1
client.addHTTPHeader('Referer',self.reffre)
client.addHTTPHeader('Cookie:',self.cookie)
client.user_agent="Mozilla-xx/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.1.3) Gecko/20090824 waigua"
service = client.getService('gameService')
return service
示例5: doVote
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def doVote(data):
appReferer = "http://vodafone.egotribe.nl/WOD2010_Loader01.swf?random=" + str(random.randint(10000, 99999))
userAgent = "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4"
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s")
try:
gw = RemotingService(
"http://flashservices.egotribe.nl/gateway.php", referer=appReferer, logger=logging, user_agent=userAgent
)
gw.addHTTPHeader("Accept-encoding", "gzip")
service = gw.getService("vodafoneGadget")
print service.saveVote(data)
except:
pass
示例6: resolve_playback_url
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def resolve_playback_url(self, key):
user_agent = getUserAgent()
self._addon.log_notice("Using user agent '%s'" % user_agent)
svc = RemotingService(self._AMF_ENDPOINT, amf_version = 0, user_agent = user_agent)
svc.addHTTPHeader('Cookie', 'r=' + self._state['rdio_cookie'])
svc.addHTTPHeader('Host', 'www.rdio.com')
rdio_svc = svc.getService('rdio')
playback_token = self._state['playback_token']
secret_string = key + playback_token + self._RDIO_PLAYBACK_SECRET
secret = self._RDIO_PLAYBACK_SECRET_SEED
for c in secret_string:
secret = ((secret << 5) + secret + ord(c)) % 65536;
playerName = 'api_%s' % str(int(math.floor(random.random() * 1000000)))
pi = rdio_svc.getPlaybackInfo({
'domain': self._RDIO_DOMAIN,
'playbackToken': playback_token,
'manualPlay': False,
'requiresUnlimited': False,
'playerName': playerName,
'type': 'flash',
'secret': secret,
'key': key})
if not pi:
raise Exception, 'Failed to get playback info'
if not pi['canStream']:
self._addon.log_notice('Streaming key %s is not allowed' % key)
return None
rtmp_info = {
'rtmp': 'rtmpe://%s:1935%s' % (pi['streamHost'], pi['streamApp']),
'app': pi['streamApp'][1:],
'playpath': 'mp3:%s' % pi['surl']
}
stream_url = rtmp_info['rtmp']
for key, value in rtmp_info.items():
stream_url += '' if key == 'rtmp' else ' %s=%s' % (key, value)
self._addon.log_debug("Resolved playback URL for key '%s' to %s" % (key, stream_url))
return stream_url
示例7: connect
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
def connect(email=None, base_url=None):
if not base_url: base_url = 'http://localhost:8080'
gw = RemotingService(base_url + '/gateway')
if email: gw.addHTTPHeader('Cookie', login_cookie(email, base_url))
return gw.getService('grocery')
示例8: int
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
dest="host", help="Host address [default: %default]")
parser.add_option("-u", "--username", default="nick",
dest="username", help="Password [default: %default]")
parser.add_option("-k", "--password", default="nick",
dest="password", help="Username [default: %default]")
parser.add_option("-r", "--realm", default=host_info[2],
dest="realm", help="Realm [default: %default]")
(opt, args) = parser.parse_args()
realm = opt.realm
credentials = base64.encodestring('%s:%s' % (opt.username, opt.password))[:-1]
logging.debug('Realm: %s' % opt.realm)
logging.debug('Username: %s' % opt.username)
logging.debug('Password: %s' % opt.password)
url = 'http://%s:%d/gateway' % (opt.host, int(opt.port))
client = RemotingService(url, logger=logging)
client.addHTTPHeader("WWW-Authenticate", 'Basic realm="%s"' % realm)
client.addHTTPHeader("Authorization", 'Basic %s' % credentials)
service = client.getService('auth.echo')
try:
result = service('Hello world!')
except RemotingError, e:
result = "Incorrect username/password!"
logging.info(result)
示例9: xrange
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
for _ in xrange(6):
try:
cookie, uid = get_cookie(username, password)
break
except:
print u"登录失败, 重试."
continue
else:
print u"你比渔民杯具, 谢谢."
sys.exit(-1)
print u"获得 Uid:", uid
# AMF 连接设置
client = RemotingService("http://xiaonei.paopaoyu.cn/gateway/")
client.addHTTPHeader('Referer', refer)
client.addHTTPHeader('Connection', "close")
client.addHTTPHeader('Cookie', cookie)
client.user_agent = user_agent
#"Mozilla/5.0 (X11; Linux mips; U; zh-cn) Gecko/20091010 BeiJu/0.0.1"
membersService = client.getService("membersService")
productsService = client.getService("productsService") # // 鱼市
gameService = client.getService("gameService") # // 抓鱼
faqsService = client.getService("faqsService") # // FAQ, 暂时没用
spacesService = client.getService("spacesService") # //
almanacService = client.getService("almanacService") # // 图鉴
inviteService = client.getService("inviteService") # // 邀请
pubseaService = client.getService("pubseaService") # //
syntheticService = client.getService("syntheticService") # //Fuck it
示例10: RemotingService
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
#!/usr/bin/env python
import logging, binascii, rc4, random, hashlib, names, time, urllib2
from pprint import pprint
from pyamf.remoting.client import RemotingService
appReferer = 'http://vodafone.egotribe.nl/WOD2010_Loader01.swf?random='+str(random.randint(10000, 99999))
userAgent = 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/533.4 (KHTML, like Gecko) Chrome/5.0.375.127 Safari/533.4'
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)-5.5s [%(name)s] %(message)s'
)
try:
gw = RemotingService('http://flashservices.egotribe.nl/gateway.php', referer=appReferer, logger=logging, user_agent=userAgent)
gw.addHTTPHeader("Accept-encoding", "gzip")
service = gw.getService('vodafoneGadget')
print service.saveVote("z8f1318468949a919a8663a68dcb613b683d0b98a443ca9c910071f259b8383d0991b9c9a5fb157cdfcc08bd87fe4baba37e06f9eab6e909b4e9c0c80c94be1dbbd007369b7cbd6daaf983b61e408869c1d1d6e863aa2bc0dfe91f71d30946532c12a8db9bcc6498e493350c6e9ea9a1421a12233d89d6f25c62e798c25aa610558c7c47a1dea7841b41946c905e7")
except:
pass
示例11: RemotingService
# 需要导入模块: from pyamf.remoting.client import RemotingService [as 别名]
# 或者: from pyamf.remoting.client.RemotingService import addHTTPHeader [as 别名]
from pyamf.remoting.client import RemotingService
gw = RemotingService('http://demo.pyamf.org/gateway/recordset')
gw.addHTTPHeader("Accept-encoding", "gzip")
gw.addHTTPHeader('Set-Cookie', 'sessionid=QT3cUmACNeKQo5oPeM0')
gw.removeHTTPHeader('Set-Cookie')
username = 'admin'
password = 'admin'
auth = ('%s:%s' % (username, password)).encode('base64')[:-1]
gw.addHTTPHeader("Authorization", "Basic %s" % auth)
service = gw.getService('service')
print service.getLanguages()