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, 2),
"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
import re

bpy.types.WindowManager.RSSadress = bpy.props.StringProperty(name='', default='http://feeds.feedburner.com/BlenderNation')

def getRss(adress):
try:
page = req.urlopen(adress).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"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = 'world'


#adress = bpy.context.window_manager.RSSadress[1]['default']
tree = getRss(bpy.context.window_manager.RSSadress)

def draw(self, context):
layout = self.layout
row = layout.row()
row.scale_y=2
row.prop(context.window_manager, "RSSadress")
row.operator('world.reloadrss', text='Reload')
width=100
for i in context.screen.areas:
if i.type == 'PROPERTIES':
width = i.width
print(width)
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')
col = box.column()
col.scale_y=1.5
col.operator('wm.url_open', text=title.text).url = link.text
dtext_ = re.split('<br/>',description.text)[0]
dtext=''
for a in re.split('&#.....', dtext_):
dtext += a
labeltext = []
string = ''
k=0
for j in dtext:
if k == width//7:
k=0
labeltext.append(string)
string = ''
k+=1
string+=j
col = box.column()
col.scale_y=0.6
for t in labeltext:
col.label(t)
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(context.window_manager.RSSadress)
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, 2),
  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. import re
  20.  
  21. bpy.types.WindowManager.RSSadress = bpy.props.StringProperty(name='', default='http://feeds.feedburner.com/BlenderNation')
  22.  
  23. def getRss(adress):
  24.     try:
  25.         page = req.urlopen(adress).read().decode('utf8')
  26.     except err.URLError:
  27.         page = None
  28.        
  29.     tree = ET.XML(page) if page else None
  30.    
  31.     return tree    
  32.  
  33. class RssPanel(bpy.types.Panel):
  34.     ''' Read feed '''
  35.     bl_label = "RSS"
  36.     bl_space_type = 'PROPERTIES'
  37.     bl_region_type = 'WINDOW'
  38.     bl_context = 'world'
  39.    
  40.    
  41.     #adress = bpy.context.window_manager.RSSadress[1]['default']
  42.     tree = getRss(bpy.context.window_manager.RSSadress)
  43.    
  44.     def draw(self, context):
  45.         layout = self.layout
  46.         row = layout.row()
  47.         row.scale_y=2
  48.         row.prop(context.window_manager, "RSSadress")
  49.         row.operator('world.reloadrss', text='Reload')
  50.         width=100
  51.         for i in context.screen.areas:
  52.             if i.type == 'PROPERTIES':
  53.                 width = i.width
  54.                 print(width)
  55.         if self.tree:  
  56.             for el in self.tree.getchildren():
  57.                 for i in el.findall('item'):
  58.                     box = layout.box()
  59.                     title = i.find('title')
  60.                     link = i.find('link')
  61.                     description = i.find('description')
  62.                     col = box.column()
  63.                     col.scale_y=1.5
  64.                     col.operator('wm.url_open', text=title.text).url = link.text
  65.                     dtext_ = re.split('<br/>',description.text)[0]
  66.                     dtext=''
  67.                     for a in re.split('&#.....', dtext_):
  68.                         dtext += a
  69.                     labeltext = []
  70.                     string = ''
  71.                     k=0
  72.                     for j in dtext:
  73.                         if k == width//7:
  74.                             k=0
  75.                             labeltext.append(string)
  76.                             string = ''
  77.                         k+=1
  78.                         string+=j
  79.                     col = box.column()
  80.                     col.scale_y=0.6
  81.                     for t in labeltext:
  82.                         col.label(t)
  83.         else:
  84.             layout.label('No connection to Internet!')
  85.  
  86.          
  87. class reloadRSS(bpy.types.Operator):
  88.     bl_label = "Reload operator"
  89.     bl_idname = "world.reloadrss"
  90.     bl_description = "Reload"
  91.  
  92.     def invoke(self, context, event):
  93.         bpy.types.RssPanel.tree = getRss(context.window_manager.RSSadress)      
  94.         return{"FINISHED"}
  95.              
  96. # registering and menu integration
  97. def register():
  98.     bpy.utils.register_class(RssPanel)
  99.     bpy.utils.register_class(reloadRSS)
  100.  
  101. # unregistering and removing menus
  102. def unregister():
  103.     bpy.utils.unregister_class(RssPanel)
  104.     bpy.utils.unregister_class(reloadRSS)
  105.  
  106. if __name__ == "__main__":
  107.     register()
  108.  
go to heaven