Repository navigation
Expand file tree
/
Copy pathextensions.py
More file actions
52 lines (44 loc) · 1.61 KB
/
Copy pathextensions.py
File metadata and controls
52 lines (44 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
"""rfeed extensions that implement https://blog.feedly.com/10-ways-to-optimize-your-feed-for-feedly/."""
from rfeed import Serializable, Extension
class MediaContent(Extension):
def get_namespace(self):
return {
"xmlns:content": "http://purl.org/rss/1.0/modules/content/",
'xmlns:media': 'http://search.yahoo.com/mrss/',
}
class MediaItem(Serializable):
def __init__(self, url: str, type: str, medium: str, isDefault: bool = False):
Serializable.__init__(self)
self.url = url
self.type = type
self.medium = medium
self.isDefault = isDefault
def publish(self, handler):
Serializable.publish(self, handler)
self._write_element(
"content:media",
None,
{
"url": self.url,
"medium": self.medium,
"type": self.type,
"isDefault": str(self.isDefault).lower(),
}
)
class Webfeeds(Extension):
def get_namespace(self):
return {'xmlns:webfeeds': 'http://webfeeds.org/rss/1.0'}
class WebfeedsIcon(Serializable):
def __init__(self, url: str):
Serializable.__init__(self)
self.url = url
def publish(self, handler):
Serializable.publish(self, handler)
self._write_element("webfeeds:icon", self.url)
class WebfeedsCover(Serializable):
def __init__(self, url: str):
Serializable.__init__(self)
self.url = url
def publish(self, handler):
Serializable.publish(self, handler)
self._write_element("webfeeds:cover", None, {'image': self.url})