-
Notifications
You must be signed in to change notification settings - Fork 1
/
rssfeed.py
55 lines (50 loc) · 1.7 KB
/
rssfeed.py
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
53
54
55
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = '[email protected]'
import sys
try:
import html2text
except ImportError as exc:
print('Error: failed to import module. ({}). \nInstall missing modules using '
'"sudo pip install -r requirements.txt"'.format(exc))
sys.exit(0)
class RssFeed:
def __init__(self, name, url, iconurl, user, channel, showname, showtitle, showdescription, showurl):
self.Name = name
self.Url = url
self.Iconurl = iconurl
self.User = user
self.Channel = channel
self.ShowName = showname
self.ShowTitle = showtitle
self.ShowDescription = showdescription
self.ShowUrl = showurl
self.LastTitle = ''
self.NewTitle = ''
self.ArticleUrl = ''
self.Description = ''
def jointext(self):
text = ''
h = html2text.HTML2Text()
h.ignore_links = True
self.Description = h.handle(self.Description)
if self.ShowName == True:
text += "_" + self.Name + '_\n'
if self.ShowTitle == True:
text += '### [' + self.NewTitle + '](' + self.ArticleUrl + ')\n'
if self.ShowDescription == True:
text += self.Description + '\n'
if self.ShowUrl == True:
text += self.ArticleUrl
return text
def env_definition(self):
text = '\nRSS_FEED_' + self.Name
text += '=\'' + self.Url
text += ';' + self.Iconurl
text += ';' + self.Channel
text += ';' + str(self.ShowName)
text += ';' + str(self.ShowTitle)
text += ';' + str(self.ShowDescription)
text += ';' + str(self.ShowUrl)
text += '\''
return text