Advertisement
Guest User

Untitled

a guest
May 24th, 2011
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.07 KB | None | 0 0
  1. import xbmcplugin,xbmcaddon
  2. import xbmc
  3. import xbmcgui
  4. import urllib
  5. import urllib2
  6. import sys
  7. import os
  8.  
  9. pluginhandle = int (sys.argv[1])
  10. """
  11. PARSE ARGV
  12. """
  13.  
  14. class _Info:
  15. def __init__( self, *args, **kwargs ):
  16. self.__dict__.update( kwargs )
  17.  
  18. exec "args = _Info(%s)" % (urllib.unquote_plus(sys.argv[2][1:].replace("&", ", ").replace('"','\'')) , )
  19.  
  20.  
  21.  
  22. """
  23. DEFINE URLS
  24. """
  25. BASE_URL = "http://www.cbs.com/video/"
  26. BASE = "http://www.cbs.com"
  27.  
  28. imagepath = os.path.join(os.getcwd().replace(';', ''),'resources','images')
  29.  
  30. """
  31. GET SETTINGS
  32. """
  33.  
  34. settings={}
  35. #settings general
  36. quality = ['2162458', '1362458', '772426', '472458', '340426']
  37. addon = xbmcaddon.Addon(id='plugin.video.cbs')
  38. selectquality = int(addon.getSetting('quality'))
  39. translated_string = addon.getLocalizedString(30000)
  40. settings['quality'] = quality[selectquality]
  41. settings['proxy'] = addon.getSetting('us_proxy_enable')
  42.  
  43.  
  44.  
  45. """
  46. ADD DIRECTORY
  47. """
  48.  
  49. def addDirectory(name, url='', mode='', page='optionlist', updatelist='false', thumb=''):
  50. ok=True
  51. u = sys.argv[0]
  52. u += '?url="'+urllib.quote_plus(url)+'"'
  53. u += '&mode="'+mode+'"'
  54. u += '&name="'+urllib.quote_plus(name.replace("'",''))+'"'
  55. u += '&page="'+urllib.quote_plus(page)+'"'
  56. u += '&updatelist="'+urllib.quote_plus(updatelist)+'"'
  57. liz=xbmcgui.ListItem(name, iconImage=thumb, thumbnailImage=thumb)
  58. liz.setInfo( type="Video", infoLabels={ "Title":name })
  59. ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
  60. return ok
  61.  
  62. def getVIDEOS( values):
  63. try:
  64. url = 'http://www.cbs.com/sitecommon/includes/video/2009_carousel_data_multiple.php'
  65. print 'CBS --> common :: postHTTP :: url = '+url
  66. data = urllib.urlencode(values)
  67. req = urllib2.Request(url,data)
  68. req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
  69. response = urllib2.urlopen(req)
  70. link=response.read()
  71. response.close()
  72. except urllib2.URLError, e:
  73. print 'Error reason: ', e.reason
  74. return False
  75. else:
  76. return link
  77.  
  78. def getHTML( url, enableproxy = False ):
  79. try:
  80. if enableproxy == True:
  81. us_proxy = 'http://' + xbmcplugin.getSetting(pluginhandle,'us_proxy') + ':' + xbmcplugin.getSetting(pluginhandle,'us_proxy_port')
  82. print 'Using proxy: ' + us_proxy
  83. proxy_handler = urllib2.ProxyHandler({'http':us_proxy})
  84. opener = urllib2.build_opener(proxy_handler)
  85. urllib2.install_opener(opener)
  86.  
  87. print 'CBS --> common :: getHTML :: url = '+url
  88. req = urllib2.Request(url)
  89. req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
  90. response = urllib2.urlopen(req)
  91. link=response.read()
  92. response.close()
  93. except urllib2.URLError, e:
  94. print 'Error reason: ', e.reason
  95. return False
  96. else:
  97. return link
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement