Creation of torrent extention
This commit is contained in:
parent
290045ac49
commit
6b7c44eeb3
1 changed files with 44 additions and 0 deletions
44
feedgen/ext/torrent.py
Normal file
44
feedgen/ext/torrent.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
feedgen.ext.podcast
|
||||
~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Extends the FeedGenerator to produce torrent feeds.
|
||||
|
||||
:copyright: 2016, Raspbeguy <raspbeguy@hashtagueule.fr>
|
||||
|
||||
:license: FreeBSD and LGPL, see license.* for more details.
|
||||
'''
|
||||
|
||||
from lxml import etree
|
||||
from feedgen.ext.base import BaseExtension,BaseEntryExtension
|
||||
|
||||
TORRENT_NS = 'http://xmlns.ezrss.it/0.1/dtd/'
|
||||
|
||||
class TorrentExtension(BaseExtension):
|
||||
'''FeedGenerator extension for torrent feeds.
|
||||
'''
|
||||
|
||||
|
||||
def extend_ns(self):
|
||||
return {'torrent' : TORRENT_NS}
|
||||
|
||||
|
||||
class TorrentEntryExtension(BaseEntryExtension):
|
||||
'''FeedEntry extention for torrent feeds
|
||||
'''
|
||||
|
||||
|
||||
def __init__(self):
|
||||
self.__torrent_enclosure = None
|
||||
self.__torrent_media = None
|
||||
self.__torrent_guid = None
|
||||
|
||||
|
||||
def extend_rss(self, entry):
|
||||
'''Add additional fields to an RSS item.
|
||||
|
||||
:param feed: The RSS item XML element to use.
|
||||
'''
|
||||
if self.__torrent_enclosure:
|
||||
enclosure = etree.SubElement(entry, '{%s}enclosure' % TORRENT_NS)
|
Loading…
Reference in a new issue