Paste Code
Paste Blends
Paste Images
# nikitron.cc.ua ordered for this. Much thanks to Nikolay Fomichev https://vk.com/pythal
bl_info = {
"name": "RSS",
"version": (0, 1, 1),
"blender": (2, 6, 9),
"category": "World",
"author": "Nikolay Fomichev",
"location": "World",
"description": "makes RSS appears in world propertyes",
"warning": "",
"wiki_url": "",
"tracker_url": "",
}

import bpy
import urllib.error as err
import urllib.request as req
from xml.etree import ElementTree as ET

def getRss():
try:
page = req.urlopen('http://feeds.feedburner.com/BlenderNation').read().decode('utf8')
except err.URLError:
page = None

tree = ET.XML(page) if page else None

return tree

class RssPanel(bpy.types.Panel):
''' Read feed '''
bl_label = "RSS of BlenderNation"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "world"

tree = getRss()

def draw(self, context):
layout = self.layout
row = layout.row()
row.operator('world.reloadrss', text='Reload')

if self.tree:
for el in self.tree.getchildren():
for i in el.findall('item'):
box = layout.box()

title = i.find('title')
link = i.find('link')
description = i.find('description')

box.operator('wm.url_open', text=title.text).url = link.text
box.label(description.text)
else:
layout.label('No connection to Internet!')


class reloadRSS(bpy.types.Operator):
bl_label = "Reload operator"
bl_idname = "world.reloadrss"
bl_description = "Reload"

def invoke(self, context, event):
bpy.types.RssPanel.tree = getRss()
return{"FINISHED"}

# registering and menu integration
def register():
bpy.utils.register_class(RssPanel)
bpy.utils.register_class(reloadRSS)

# unregistering and removing menus
def unregister():
bpy.utils.unregister_class(RssPanel)
bpy.utils.unregister_class(reloadRSS)

if __name__ == "__main__":
register()
  1. # nikitron.cc.ua ordered for this. Much thanks to Nikolay Fomichev https://vk.com/pythal
  2. bl_info = {
  3.     "name": "RSS",
  4.     "version": (0, 1, 1),
  5.     "blender": (2, 6, 9),
  6.     "category": "World",
  7.     "author": "Nikolay Fomichev",
  8.     "location": "World",
  9.     "description": "makes RSS appears in world propertyes",
  10.     "warning": "",
  11.     "wiki_url": "",          
  12.     "tracker_url": "",  
  13. }
  14.  
  15. import bpy
  16. import urllib.error as err
  17. import urllib.request as req
  18. from xml.etree import ElementTree as ET
  19.  
  20. def getRss():
  21.     try:
  22.         page = req.urlopen('http://feeds.feedburner.com/BlenderNation').read().decode('utf8')
  23.     except err.URLError:
  24.         page = None
  25.        
  26.     tree = ET.XML(page) if page else None
  27.    
  28.     return tree    
  29.  
  30. class RssPanel(bpy.types.Panel):
  31.     ''' Read feed '''
  32.     bl_label = "RSS of BlenderNation"
  33.     bl_space_type = 'PROPERTIES'
  34.     bl_region_type = 'WINDOW'
  35.     bl_context = "world"
  36.        
  37.     tree = getRss()
  38.    
  39.     def draw(self, context):
  40.         layout = self.layout
  41.         row = layout.row()
  42.         row.operator('world.reloadrss', text='Reload')
  43.    
  44.         if self.tree:  
  45.             for el in self.tree.getchildren():
  46.                 for i in el.findall('item'):
  47.                     box = layout.box()
  48.                    
  49.                     title = i.find('title')
  50.                     link = i.find('link')
  51.                     description = i.find('description')
  52.                    
  53.                     box.operator('wm.url_open', text=title.text).url = link.text
  54.                     box.label(description.text)
  55.         else:
  56.             layout.label('No connection to Internet!')
  57.  
  58.          
  59. class reloadRSS(bpy.types.Operator):
  60.     bl_label = "Reload operator"
  61.     bl_idname = "world.reloadrss"
  62.     bl_description = "Reload"
  63.  
  64.     def invoke(self, context, event):
  65.         bpy.types.RssPanel.tree = getRss()      
  66.         return{"FINISHED"}
  67.              
  68. # registering and menu integration
  69. def register():
  70.     bpy.utils.register_class(RssPanel)
  71.     bpy.utils.register_class(reloadRSS)
  72.  
  73. # unregistering and removing menus
  74. def unregister():
  75.     bpy.utils.unregister_class(RssPanel)
  76.     bpy.utils.unregister_class(reloadRSS)
  77.  
  78. if __name__ == "__main__":
  79.     register()
  80.  
go to heaven