Add Media RSS to RSS
This patch adds the necessary RSS extension to ensure that added Media RSS elements end up in the resulting RSS XML. Part of #58
This commit is contained in:
parent
ba5bbd2256
commit
8487af298e
2 changed files with 37 additions and 2 deletions
|
@ -5,7 +5,7 @@
|
|||
|
||||
Extends the feedgen to produce media tags.
|
||||
|
||||
:copyright: 2013-2016, Lars Kiesow <lkiesow@uos.de>
|
||||
:copyright: 2013-2017, Lars Kiesow <lkiesow@uos.de>
|
||||
|
||||
:license: FreeBSD and LGPL, see license.* for more details.
|
||||
'''
|
||||
|
@ -29,7 +29,7 @@ class MediaEntryExtension(BaseEntryExtension):
|
|||
'''
|
||||
|
||||
def __init__(self):
|
||||
self.__media_content = None
|
||||
self.__media_content = []
|
||||
self.__media_thumbnail = None
|
||||
|
||||
def extend_atom(self, entry):
|
||||
|
@ -84,6 +84,9 @@ class MediaEntryExtension(BaseEntryExtension):
|
|||
|
||||
return entry
|
||||
|
||||
def extend_rss(self, item):
|
||||
return self.extend_atom(item)
|
||||
|
||||
def media_content(self, url=None, fileSize=None, type=None, medium=None,
|
||||
isDefault=None, expression=None, bitrate=None,
|
||||
framerate=None, samplingrate=None, channels=None,
|
||||
|
|
|
@ -194,3 +194,35 @@ class TestExtensionTorrent(unittest.TestCase):
|
|||
filename = root.xpath('/rss/channel/item/torrent:filename/text()',
|
||||
namespaces=ns)
|
||||
assert filename == ['file.xy']
|
||||
|
||||
|
||||
class TestExtensionMedia(unittest.TestCase):
|
||||
|
||||
def setUp(self):
|
||||
self.fg = FeedGenerator()
|
||||
self.fg.load_extension('media')
|
||||
self.fg.id('id')
|
||||
self.fg.title('title')
|
||||
self.fg.link(href='http://example.com', rel='self')
|
||||
self.fg.description('description')
|
||||
|
||||
def test_media_content(self):
|
||||
fe = self.fg.add_item()
|
||||
fe.id('id')
|
||||
fe.title('title')
|
||||
fe.content('content')
|
||||
fe.media.media_content(url='file1.xy')
|
||||
|
||||
ns = {'media': 'http://search.yahoo.com/mrss/',
|
||||
'a': 'http://www.w3.org/2005/Atom'}
|
||||
# Check that we have the item in the resulting RSS
|
||||
root = etree.fromstring(self.fg.rss_str())
|
||||
url = root.xpath('/rss/channel/item/media:group/media:content[1]/@url',
|
||||
namespaces=ns)
|
||||
assert url == ['file1.xy']
|
||||
|
||||
# Check that we have the item in the resulting Atom feed
|
||||
root = etree.fromstring(self.fg.atom_str())
|
||||
url = root.xpath('/a:feed/a:entry/media:group/media:content[1]/@url',
|
||||
namespaces=ns)
|
||||
assert url == ['file1.xy']
|
||||
|
|
Loading…
Reference in a new issue