Advertisement
Guest User

1st tv

a guest
Mar 11th, 2016
572
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.48 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. """
  4. Kodi plugin: plays latest news from Russian 1tv.
  5.  
  6. """
  7.  
  8. import sys
  9. import urllib2
  10. from xml.etree import ElementTree
  11. from HTMLParser import HTMLParser
  12. import xbmc
  13. import xbmcgui
  14. import xbmcplugin
  15.  
  16. __author__ = "Dmitry Sandalov"
  17. __copyright__ = "Copyright 2014, Dmitry Sandalov"
  18. __credits__ = []
  19. __license__ = "GNU GPL v2.0"
  20. __version__ = "1.0.5"
  21. __maintainer__ = "Dmitry Sandalov"
  22. __email__ = "dmitry@sandalov.org"
  23. __status__ = "Development"
  24.  
  25. html = urllib2.urlopen('http://www.1tv.ru/newsvideoarchive/').read()
  26. col=html.find('/iframed/embednewslist.html?id=')
  27. id=html[col+31:col+44].replace('"','')
  28. html = urllib2.urlopen('http://www.1tv.ru/swfxml/newsvyp/'+id).read()
  29.  
  30. addon_handle = int(sys.argv[1])
  31. xbmcplugin.setContent(addon_handle, 'movies')
  32.  
  33. root = ElementTree.fromstring(html)
  34. namespace = "{http://search.yahoo.com/mrss/}"
  35. items = []
  36. playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
  37. xbmc.PlayList.clear(playlist)
  38. for item in root.getiterator('item'):
  39.     url = item.find(namespace + "content").attrib['url']
  40.     title = item.find('title').text
  41.     img = item.find(namespace + "thumbnail").attrib['url']
  42.     li = xbmcgui.ListItem(label=title, iconImage=img, thumbnailImage=img)
  43.     items.append((url, li, False,))
  44.     playlist.add(url=url, listitem=li, index=len(items))
  45. xbmcplugin.addDirectoryItems(addon_handle, items, totalItems=len(items))
  46. xbmc.Player().play(playlist)
  47. xbmcplugin.endOfDirectory(addon_handle)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement