PageRenderTime 55ms CodeModel.GetById 22ms RepoModel.GetById 1ms app.codeStats 0ms

/addons/plugin.video.turbofilm.tv/default.py

http://seppius-xbmc-repo.googlecode.com/
Python | 615 lines | 587 code | 10 blank | 18 comment | 15 complexity | 55679ffe6764e2ca314abc1f77207b0a MD5 | raw file
Possible License(s): GPL-3.0, AGPL-1.0
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. # *
  4. # *
  5. # * This Program is free software; you can redistribute it and/or modify
  6. # * it under the terms of the GNU General Public License as published by
  7. # * the Free Software Foundation; either version 2, or (at your option)
  8. # * any later version.
  9. # *
  10. # * This Program is distributed in the hope that it will be useful,
  11. # * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # * GNU General Public License for more details.
  14. # *
  15. # * You should have received a copy of the GNU General Public License
  16. # * along with this program; see the file COPYING. If not, write to
  17. # * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # * http://www.gnu.org/copyleft/gpl.html
  19. import urllib, urllib2, cookielib, re, xbmcaddon, string, xbmc, xbmcgui, xbmcplugin, os, httplib, socket
  20. import base64
  21. import random
  22. import sha
  23. __settings__ = xbmcaddon.Addon(id='plugin.video.turbofilm.tv')
  24. __language__ = __settings__.getLocalizedString
  25. USERNAME = __settings__.getSetting('username')
  26. USERPASS = __settings__.getSetting('password')
  27. handle = int(sys.argv[1])
  28. PLUGIN_NAME = 'Turbofilm.TV'
  29. SITE_HOSTNAME = 'turbofilm.tv'
  30. SITEPREF = 'http://%s' % SITE_HOSTNAME
  31. SITE_URL = SITEPREF + '/'
  32. phpsessid_file = os.path.join(xbmc.translatePath('special://temp/'), 'plugin_video_turbofilmtv.sess')
  33. plotdescr_file = os.path.join(xbmc.translatePath('special://temp/'), 'plugin_video_turbofilmtv.plot')
  34. thumb = os.path.join( os.getcwd(), "icon.png" )
  35. def run_once():
  36. global USERNAME, USERPASS
  37. while (Get('/') == None):
  38. user_keyboard = xbmc.Keyboard()
  39. user_keyboard.setHeading(__language__(30001))
  40. user_keyboard.doModal()
  41. if (user_keyboard.isConfirmed()):
  42. USERNAME = user_keyboard.getText()
  43. pass_keyboard = xbmc.Keyboard()
  44. pass_keyboard.setHeading(__language__(30002))
  45. pass_keyboard.setHiddenInput(True)
  46. pass_keyboard.doModal()
  47. if (pass_keyboard.isConfirmed()):
  48. USERPASS = pass_keyboard.getText()
  49. __settings__.setSetting('username', USERNAME)
  50. __settings__.setSetting('password', USERPASS)
  51. else:
  52. return False
  53. else:
  54. return False
  55. return True
  56. def Get(url, ref=None):
  57. use_auth = False
  58. inter = 2
  59. while inter:
  60. wurl = SITEPREF + url
  61. cj = cookielib.CookieJar()
  62. h = urllib2.HTTPCookieProcessor(cj)
  63. opener = urllib2.build_opener(h)
  64. urllib2.install_opener(opener)
  65. post = None
  66. if use_auth:
  67. post = urllib.urlencode({'login': USERNAME, 'passwd': USERPASS})
  68. url = SITE_URL
  69. request = urllib2.Request(wurl, post)
  70. request.add_header('User-Agent', 'Opera/9.80 (X11; Linux i686; U; ru) Presto/2.6.30 Version/10.70')
  71. request.add_header('Host', SITE_HOSTNAME)
  72. request.add_header('Accept', 'text/html, application/xml, application/xhtml+xml, */*')
  73. request.add_header('Accept-Language', 'ru,en;q=0.9')
  74. if ref != None:
  75. request.add_header('Referer', ref)
  76. if (os.path.isfile(phpsessid_file) and (not use_auth)):
  77. fh = open(phpsessid_file, 'r')
  78. phpsessid = fh.read()
  79. fh.close()
  80. request.add_header('Cookie', 'IAS_ID=' + phpsessid)
  81. o = urllib2.urlopen(request)
  82. for index, cookie in enumerate(cj):
  83. cookraw = re.compile('<Cookie IAS_ID=(.*?) for.*/>').findall(str(cookie))
  84. if len(cookraw) > 0:
  85. fh = open(phpsessid_file, 'w')
  86. fh.write(cookraw[0])
  87. fh.close()
  88. http = o.read()
  89. o.close()
  90. if (http.find('<div class="loginblock" id="loginblock">') == -1):
  91. return http
  92. else:
  93. use_auth = True
  94. url = '/Signin/'
  95. inter = inter - 1
  96. return None
  97. def get_params():
  98. param=[]
  99. paramstring=sys.argv[2]
  100. if len(paramstring)>=2:
  101. params=sys.argv[2]
  102. cleanedparams=params.replace('?','')
  103. if (params[len(params)-1]=='/'):
  104. params=params[0:len(params)-2]
  105. pairsofparams=cleanedparams.split('&')
  106. param={}
  107. for i in range(len(pairsofparams)):
  108. splitparams={}
  109. splitparams=pairsofparams[i].split('=')
  110. if (len(splitparams))==2:
  111. param[splitparams[0]]=splitparams[1]
  112. return param
  113. def ShowSeries(url):
  114. http = Get(url)
  115. if http == None:
  116. xbmc.output('[%s] ShowSeries() Error 1: Not received data when opening URL=%s' % (PLUGIN_NAME, url))
  117. return
  118. #xbmc.output(http)
  119. raw1 = re.compile('<div id="series">(.*?)<div id="footer">', re.DOTALL).findall(http)
  120. if len(raw1) == 0:
  121. xbmc.output('[%s] ShowSeries() Error 2: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  122. xbmc.output(http)
  123. return
  124. #xbmc.output(raw1[0])
  125. raw2 = re.compile('\s<a href="(.*?)">\s(.*?)</a>', re.DOTALL).findall(raw1[0])
  126. if len(raw1) == 0:
  127. xbmc.output('[%s] ShowSeries() Error 3: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  128. xbmc.output(raw1[0])
  129. return
  130. x = 1;
  131. for wurl, http2 in raw2:
  132. raw_img = re.compile('<img src="(.*?)".*/>').findall(http2)
  133. if len(raw_img) == 0:
  134. Thumb = thumb
  135. else:
  136. Thumb = SITEPREF + raw_img[0]
  137. raw_en = re.compile('<span class="serieslistboxen">(.*?)</span>').findall(http2)
  138. if len(raw_en) == 0:
  139. TitleEN = 'No title'
  140. else:
  141. TitleEN = raw_en[0]
  142. raw_ru = re.compile('<span class="serieslistboxru">(.*?)</span>').findall(http2)
  143. if len(raw_ru) == 0:
  144. TitleRU = 'No title'
  145. else:
  146. TitleRU = raw_ru[0]
  147. Descr = ''
  148. raw_des = re.compile('<span class="serieslistboxperstext">(.*?)</span>').findall(http2)
  149. if len(raw_des) != 0:
  150. for cur_des in raw_des:
  151. Descr = Descr + cur_des + '\n'
  152. raw_des2 = re.compile('<span class="serieslistboxdesc">(.*?)</span>').findall(http2)
  153. if len(raw_des2) > 0:
  154. Descr = Descr + raw_des2[0]
  155. sindex = str(x)
  156. #xbmc.output('*** %s Thumb = %s' % (sindex, Thumb))
  157. #xbmc.output('*** %s TitleEN = %s' % (sindex, TitleEN))
  158. #xbmc.output('*** %s TitleRU = %s' % (sindex, TitleRU))
  159. #xbmc.output('*** %s Descr = %s' % (sindex, Descr))
  160. #xbmc.output('*** %s wurl = %s' % (sindex, wurl))
  161. Title = '%s. %s (%s)' % (sindex, TitleRU, TitleEN)
  162. listitem = xbmcgui.ListItem(Title, iconImage = Thumb, thumbnailImage = Thumb)
  163. listitem.setInfo(type = "Video",
  164. infoLabels = {
  165. "Title": Title,
  166. "Plot": Descr,
  167. "FolderName": TitleRU
  168. }
  169. );
  170. listitem.setProperty("Fanart_Image", Thumb);
  171. url = sys.argv[0] + '?mode=OpenSeries&url=' + urllib.quote_plus(wurl) \
  172. + '&title=' + urllib.quote_plus(Title)
  173. xbmcplugin.addDirectoryItem(handle, url, listitem, True)
  174. x += 1
  175. def OpenSeries(url, title):
  176. http = Get(url, SITEPREF + '/Series/')
  177. if http == None:
  178. xbmc.output('[%s] OpenSeries() Error 1: Not received data when opening URL=%s' % (PLUGIN_NAME, url))
  179. return
  180. raw_topimg = re.compile('<div class="topimgseries">\s*<img src="(.*?)"').findall(http)
  181. if len(raw_topimg) == 0:
  182. TopIMG = thumb
  183. else:
  184. TopIMG = SITEPREF + raw_topimg[0]
  185. raw1 = re.compile('<div class="sserieslistbox">(.*?)<div class="sseriesrightbox">', re.DOTALL).findall(http)
  186. if len(raw1) == 0:
  187. xbmc.output('[%s] OpenSeries() Error 2: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  188. xbmc.output(http)
  189. return
  190. raw2 = re.compile('<a href="(.+?)">\s(.*?)</a>', re.DOTALL).findall(raw1[0])
  191. if len(raw1) == 0:
  192. xbmc.output('[%s] OpenSeries() Error 3: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  193. xbmc.output(raw1[0])
  194. return
  195. x = 1
  196. for wurl, http2 in raw2:
  197. #xbmc.output('************** wurl = %s' % wurl)
  198. #xbmc.output('http2 = %s' % http2)
  199. raw_img = re.compile('<img src="(.*?)".*/>').findall(http2)
  200. if len(raw_img) == 0:
  201. Thumb = TopIMG
  202. else:
  203. Thumb = raw_img[0]
  204. raw_en = re.compile('<span class="sserieslistonetxten">(.*?)</span>').findall(http2)
  205. if len(raw_en) == 0:
  206. TitleEN = 'No title'
  207. else:
  208. TitleEN = raw_en[0]
  209. raw_ru = re.compile('<span class="sserieslistonetxtru">(.*?)</span>').findall(http2)
  210. if len(raw_ru) == 0:
  211. TitleRU = 'No title'
  212. else:
  213. TitleRU = raw_ru[0]
  214. raw_se = re.compile(u'<span class="sserieslistonetxtse">?????: (.*?)</span>').findall(http2)
  215. if len(raw_se) == 0:
  216. SeaNUM = 'Season not specified'
  217. else:
  218. SeaNUM = raw_se[0]
  219. raw_ep = re.compile('<span class="sserieslistonetxtep">??????: (.*?)</span>').findall(http2)
  220. if len(raw_ep) == 0:
  221. EpiNUM = 'The episode is not specified'
  222. else:
  223. EpiNUM = raw_ep[0]
  224. sindex = str(x)
  225. xbmc.output('*** %s Thumb = %s' % (sindex, Thumb))
  226. xbmc.output('*** %s TitleEN = %s' % (sindex, TitleEN))
  227. xbmc.output('*** %s TitleRU = %s' % (sindex, TitleRU))
  228. xbmc.output('*** %s SeaNUM = %s' % (sindex, SeaNUM))
  229. xbmc.output('*** %s EpiNUM = %s' % (sindex, EpiNUM))
  230. xbmc.output('*** %s wurl = %s' % (sindex, wurl))
  231. Title = 'Episode %s: %s / %s' % (EpiNUM, TitleRU, TitleEN)
  232. Descr = 'Season: %s\nEpisode: %s' % (SeaNUM, EpiNUM)
  233. listitem = xbmcgui.ListItem(Title, iconImage = Thumb, thumbnailImage = Thumb)
  234. listitem.setInfo(type = "Video",
  235. infoLabels = {
  236. "title": Title,
  237. "tvshowtitle": title,
  238. "plot": "",
  239. "episode": EpiNUM,
  240. "season": SeaNUM,
  241. "VideoCodec": "h264"
  242. }
  243. )
  244. listitem.setProperty("Fanart_Image", Thumb)
  245. url = sys.argv[0] + '?mode=Watch&url=' + urllib.quote_plus(wurl) \
  246. + '&title=' + urllib.quote_plus(Title)
  247. xbmcplugin.addDirectoryItem(handle, url, listitem, False)
  248. x += 1
  249. raw3 = re.compile('<div class="seasonnum">(.*?)</div>', re.DOTALL).findall(http)
  250. if len(raw3) == 0:
  251. xbmc.output('[%s] OpenSeries() Error 4: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  252. xbmc.output(http)
  253. return
  254. raw4 = re.compile('<a href="(.*?)"><span class=".*">(.*?)</span></a>').findall(raw3[0])
  255. if len(raw4) == 0:
  256. xbmc.output('[%s] OpenSeries() Error 5: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  257. xbmc.output(raw3[0])
  258. return
  259. for row_url, row_name in raw4:
  260. xbmc.output('*** row_url = %s' % row_url)
  261. xbmc.output('*** row_name = %s' % row_name)
  262. listitem = xbmcgui.ListItem(row_name, iconImage = TopIMG, thumbnailImage = TopIMG)
  263. listitem.setInfo(type = "Video", infoLabels = {
  264. "Title": row_name
  265. } )
  266. url = sys.argv[0] + '?mode=OpenSeries&url=' + urllib.quote_plus(row_url) \
  267. + '&title=' + urllib.quote_plus(title + ' : ' + row_name)
  268. xbmcplugin.addDirectoryItem(handle, url, listitem, True)
  269. def Watch(url, title, img):
  270. def meta_decoder(param1):
  271. def enc_replace(param1, param2):
  272. loc_4 = []
  273. loc_5 = []
  274. loc_6 = ['2','I','0','=','3','Q','8','V','7','X','G','M','R','U','H','4','1','Z','5','D','N','6','L','9','B','W'];
  275. loc_7 = ['x','u','Y','o','k','n','g','r','m','T','w','f','d','c','e','s','i','l','y','t','p','b','z','a','J','v'];
  276. if (param2 == 'e'):
  277. loc_4 = loc_6
  278. loc_5 = loc_7
  279. if (param2 == 'd'):
  280. loc_4 = loc_7
  281. loc_5 = loc_6
  282. loc_8 = 0
  283. while (loc_8 < len(loc_4)):
  284. param1 = param1.replace(loc_4[loc_8], '___')
  285. param1 = param1.replace(loc_5[loc_8], loc_4[loc_8])
  286. param1 = param1.replace('___', loc_5[loc_8])
  287. loc_8 += 1
  288. return param1
  289. param1 = param1.replace('%2b', '+')
  290. param1 = param1.replace('%3d', '=')
  291. param1 = param1.replace('%2f', '/')
  292. param1 = enc_replace(param1, 'd')
  293. return base64.b64decode(param1)
  294. http = Get(url)
  295. if http == None:
  296. xbmc.output('[%s] Watch() Error 1: Not received data when opening URL=%s' % (PLUGIN_NAME, url))
  297. return
  298. raw1 = re.compile('<input type="hidden" id="metadata" value="(.*)" />').findall(http)
  299. if len(raw1) == 0:
  300. xbmc.output('[%s] Watch() Error 2: r.e. not found it necessary elements. URL=%s' % (PLUGIN_NAME, url))
  301. xbmc.output(http)
  302. return
  303. Metadata = raw1[0]
  304. Plot = 'No plot'
  305. raw2 = re.compile('<span class="textdesc">(.*?)</span>', re.DOTALL).findall(http)
  306. if len(raw2)> 0:
  307. Plot = raw2[0]
  308. eid = '0'
  309. raw3 = re.compile('<input type="hidden" id="eid" value="(.*?)" />').findall(http)
  310. if len(raw3) > 0:
  311. eid = raw3[0]
  312. pid = '0'
  313. raw4 = re.compile('<input type="hidden" id="pid" value="(.*?)" />').findall(http)
  314. if len(raw4) > 0:
  315. pid = raw4[0]
  316. sid = '0'
  317. raw5 = re.compile('<input type="hidden" id="sid" value="(.*?)" />').findall(http)
  318. if len(raw5) > 0:
  319. sid = raw5[0]
  320. epwatch = '0'
  321. raw6 = re.compile('<input type="hidden" id="epwatch" value="(.*?)" />').findall(http)
  322. if len(raw6) > 0:
  323. epwatch = raw6[0]
  324. sewatch = '0'
  325. raw7 = re.compile('<input type="hidden" id="sewatch" value="(.*?)" />').findall(http)
  326. if len(raw7) > 0:
  327. sewatch = raw7[0]
  328. h1 = '0'
  329. raw8 = re.compile('<input type="hidden" id="h1" value="(.*?)" />').findall(http)
  330. if len(raw8) > 0:
  331. h1 = raw8[0]
  332. Hash = '0'
  333. raw9 = re.compile('<input type="hidden" id="hash" value="(.*?)" />').findall(http)
  334. if len(raw9) > 0:
  335. Hash = raw9[0]
  336. xbmc.output('*** eid = %s' % eid)
  337. xbmc.output('*** pid = %s' % pid)
  338. xbmc.output('*** sid = %s' % sid)
  339. xbmc.output('*** epwatch = %s' % epwatch)
  340. xbmc.output('*** sewatch = %s' % sewatch)
  341. xbmc.output('*** h1 = %s' % h1)
  342. xbmc.output('*** Hash = %s' % Hash)
  343. xbmc.output('*** Metadata = %s' % Metadata)
  344. xbmc.output('*** Plot = %s' % Plot)
  345. Meta = meta_decoder(Metadata)
  346. sources2_default = ''
  347. sources2_hq = ''
  348. aspect = '0'
  349. duration = '0'
  350. hq = '1'
  351. Eid = '0'
  352. screen = ''
  353. sizes_default = '0'
  354. sizes_hq = '0'
  355. langs_en = '0'
  356. langs_ru = '0'
  357. subtitles_en = '0'
  358. subtitles_ru = '0'
  359. subtitles_en_sources = ''
  360. subtitles_ru_sources = ''
  361. r1 = re.compile('<movie>(.*?)</movie>', re.DOTALL).findall(Meta)
  362. if len(r1) > 0:
  363. r2 = re.compile('<sources2>(.*?)</sources2>', re.DOTALL).findall(r1[0])
  364. if len(r2) > 0:
  365. r3 = re.compile('<default>(.*?)</default>').findall(r2[0])
  366. if len(r3) > 0:
  367. sources2_default = r3[0]
  368. r3 = re.compile('<hq>(.*?)</hq>').findall(r2[0])
  369. if len(r3) > 0:
  370. sources2_hq = r3[0]
  371. r2 = re.compile('<aspect>(.*?)</aspect>').findall(r1[0])
  372. if len(r2) > 0:
  373. aspect = r2[0]
  374. r2 = re.compile('<duration>(.*?)</duration>').findall(r1[0])
  375. if len(r2) > 0:
  376. duration = r2[0]
  377. r2 = re.compile('<hq>(.*?)</hq>').findall(r1[0])
  378. if len(r2) > 0:
  379. hq = r2[0]
  380. r2 = re.compile('<eid>(.*?)</eid>').findall(r1[0])
  381. if len(r2) > 0:
  382. Eid = r2[0]
  383. r2 = re.compile('<screen>(.*?)</screen>').findall(r1[0])
  384. if len(r2) > 0:
  385. screen = r2[0]
  386. r2 = re.compile('<sizes>(.*?)</sizes>', re.DOTALL).findall(r1[0])
  387. if len(r2) > 0:
  388. r3 = re.compile('<default>(.*?)</default>').findall(r2[0])
  389. if len(r3) > 0:
  390. sizes_default = r3[0]
  391. r3 = re.compile('<hq>(.*?)</hq>').findall(r2[0])
  392. if len(r3) > 0:
  393. sizes_hq = r3[0]
  394. r2 = re.compile('<langs>(.*?)</langs>', re.DOTALL).findall(r1[0])
  395. if len(r2) > 0:
  396. r3 = re.compile('<en>(.*?)</en>').findall(r2[0])
  397. if len(r3) > 0:
  398. langs_en = r3[0]
  399. r3 = re.compile('<ru>(.*?)</ru>').findall(r2[0])
  400. if len(r3) > 0:
  401. langs_ru = r3[0]
  402. r2 = re.compile('<subtitles>(.*?)</subtitles>', re.DOTALL).findall(r1[0])
  403. if len(r2) > 0:
  404. r3 = re.compile('<en>(.*?)</en>').findall(r2[0])
  405. if len(r3) > 0:
  406. subtitles_en = r3[0]
  407. r3 = re.compile('<ru>(.*?)</ru>').findall(r2[0])
  408. if len(r3) > 0:
  409. subtitles_ru = r3[0]
  410. r3 = re.compile('<sources>(.*?)</sources>', re.DOTALL).findall(r2[0])
  411. if len(r3) > 0:
  412. r4 = re.compile('<en>(.*?)</en>').findall(r3[0])
  413. if len(r4) > 0:
  414. subtitles_en_sources = r4[0]
  415. r4 = re.compile('<ru>(.*?)</ru>').findall(r3[0])
  416. if len(r4) > 0:
  417. subtitles_ru = r4[0]
  418. xbmc.output(' sources2_default = %s' % sources2_default)
  419. xbmc.output(' sources2_hq = %s' % sources2_hq)
  420. xbmc.output(' aspect = %s' % aspect)
  421. xbmc.output(' duration = %s' % duration)
  422. xbmc.output(' hq = %s' % hq)
  423. xbmc.output(' Eid = %s' % Eid)
  424. xbmc.output(' screen = %s' % screen)
  425. xbmc.output(' sizes_default = %s' % sizes_default)
  426. xbmc.output(' sizes_hq = %s' % sizes_hq)
  427. xbmc.output(' langs_en = %s' % langs_en)
  428. xbmc.output(' langs_ru = %s' % langs_ru)
  429. xbmc.output(' subtitles_en = %s' % subtitles_en)
  430. xbmc.output(' subtitles_ru = %s' % subtitles_ru)
  431. xbmc.output('subtitles_en_sources = %s' % subtitles_en_sources)
  432. xbmc.output('subtitles_ru_sources = %s' % subtitles_ru_sources)
  433. Hash = Hash[::-1]
  434. Lang = 'ru'
  435. Time = '0'
  436. #p0 = 'http://cdn.turbofilm.tv'
  437. #p0 = 'http://217.199.218.60'
  438. p1 = sha.new(Lang).hexdigest()
  439. p2 = str(eid)
  440. p3 = str(sources2_default)
  441. p4 = str(Time)
  442. p5 = Hash
  443. p6 = sha.new(Hash + str(random.random())).hexdigest()
  444. p7 = sha.new(p6 + eid + 'A2DC51DE0F8BC1E9').hexdigest()
  445. retval = '/%s/%s/%s/%s/%s/%s/%s' % (p1,p2,p3,p4,p5,p6,p7)
  446. xbmc.output ('SRC file retval = %s' % retval)
  447. rurl = url.replace('/', '_')
  448. #dest = os.path.join(xbmc.translatePath('special://temp/'), rurl)
  449. #xbmc.output ('Dest file = %s' % dest)
  450. phpsessid = ''
  451. #req = urllib2.Request(durl)
  452. if os.path.isfile(phpsessid_file):
  453. fh = open(phpsessid_file, 'r')
  454. phpsessid = fh.read()
  455. fh.close()
  456. def PlayURL(path):
  457. conn = httplib.HTTPConnection('cdn.turbofilm.tv', 80, 10)
  458. headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2',\
  459. 'Host': 'cdn.turbofilm.tv',\
  460. 'Accept': '*/*',\
  461. 'Accept-Language': 'ru,en;q=0.9',\
  462. 'Accept-Charset': 'iso-8859-1, utf-8, utf-16, *;q=0.1',\
  463. 'Accept-Encoding': 'deflate, gzip, x-gzip, identity, *;q=0',\
  464. 'Referer': 'http://turbofilm.tv/media/swf/Player20.swf',\
  465. 'Cookie': 'IAS_ID='+str(phpsessid)+'; _',\
  466. 'Cookie2': '$Version=1',\
  467. 'Connection': 'Keep-Alive' }
  468. conn.request("GET", path, '', headers)
  469. response = conn.getresponse()
  470. conn.close()
  471. if(response.status == 302):
  472. xbmc.output('OK - response.status == 302')
  473. Location = response.getheader('Location') # + '@'
  474. xbmc.output('Location: %s' % Location)
  475. #item = xbmcgui.ListItem(title, iconImage = thumb, thumbnailImage = thumb)
  476. #item.setInfo(type="Video", infoLabels = {
  477. # "Title": title,
  478. # "Plot": Plot
  479. # } )
  480. h_1 = '|Referer=' + urllib.quote_plus('http://turbofilm.tv/media/swf/Player20.swf')
  481. h_2 = '&User-Agent=' + urllib.quote_plus('Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.54 Safari/535.2')
  482. h_3 = '&Accept=' + urllib.quote_plus('*/*')
  483. h_4 = '&Accept-Language=' + urllib.quote_plus('ru,en;q=0.9')
  484. h_5 = '&Accept-Charset=' + urllib.quote_plus('iso-8859-1, utf-8, utf-16, *;q=0.1')
  485. h_6 = '&Accept-Encoding=' + urllib.quote_plus('deflate, gzip, x-gzip, identity, *;q=0')
  486. h_7 = '&Connection=' + urllib.quote_plus('Keep-Alive')
  487. #
  488. finalUrl = Location + h_1 + h_2 + h_3 + h_4 + h_5 + h_6 + h_7
  489. item = xbmcgui.ListItem(title, iconImage = thumb, thumbnailImage = thumb, path = finalUrl)
  490. item.setInfo(type="Video", infoLabels = {
  491. "Title": title,
  492. "Plot": Plot
  493. } )
  494. item.setProperty("IsPlayable", "true")
  495. item.setProperty('mimetype', 'video/mp4');
  496. xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
  497. xbmc.Player().play(finalUrl, item)
  498. #xbmc.Player().play(finalItem)
  499. return
  500. return
  501. PlayURL(retval)
  502. if run_once():
  503. params = get_params()
  504. mode = None
  505. url = ''
  506. title = ''
  507. ref = ''
  508. img = ''
  509. try:
  510. mode = urllib.unquote_plus(params["mode"])
  511. except:
  512. pass
  513. try:
  514. url = urllib.unquote_plus(params["url"])
  515. except:
  516. pass
  517. try:
  518. title = urllib.unquote_plus(params["title"])
  519. except:
  520. pass
  521. try:
  522. img = urllib.unquote_plus(params["img"])
  523. except:
  524. pass
  525. if mode == None:
  526. ShowSeries('/Series/')
  527. xbmcplugin.setPluginCategory(handle, PLUGIN_NAME)
  528. xbmcplugin.endOfDirectory(handle)
  529. elif mode == 'OpenSeries':
  530. OpenSeries(url, title)
  531. xbmcplugin.setPluginCategory(handle, PLUGIN_NAME)
  532. xbmcplugin.endOfDirectory(handle)
  533. elif mode == 'Watch':
  534. Watch(url, title, img)
  535. #xbmcplugin.setPluginCategory(handle, PLUGIN_NAME)
  536. #xbmcplugin.endOfDirectory(handle)