Update Gmeek.py
This commit is contained in:
parent
5e2e881d04
commit
6ea211db05
21
Gmeek.py
21
Gmeek.py
@ -40,6 +40,7 @@ class GMEEK():
|
|||||||
user = Github(self.options.github_token)
|
user = Github(self.options.github_token)
|
||||||
self.repo = self.get_repo(user, options.repo_name)
|
self.repo = self.get_repo(user, options.repo_name)
|
||||||
self.feed = FeedGenerator()
|
self.feed = FeedGenerator()
|
||||||
|
self.oldFeedString=''
|
||||||
|
|
||||||
self.labelColorDict=json.loads('{}')
|
self.labelColorDict=json.loads('{}')
|
||||||
for label in self.repo.get_labels():
|
for label in self.repo.get_labels():
|
||||||
@ -197,17 +198,21 @@ class GMEEK():
|
|||||||
item.link(href=self.blogBase["homeUrl"]+"/"+self.blogBase["postListJson"][num]["postUrl"])
|
item.link(href=self.blogBase["homeUrl"]+"/"+self.blogBase["postListJson"][num]["postUrl"])
|
||||||
item.pubDate(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(self.blogBase["postListJson"][num]["createdAt"])))
|
item.pubDate(time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime(self.blogBase["postListJson"][num]["createdAt"])))
|
||||||
|
|
||||||
if os.path.exists(self.root_dir+'rss.xml'):
|
if self.oldFeedString!='':
|
||||||
feed.rss_file(self.root_dir+'new.xml')
|
feed.rss_file(self.root_dir+'new.xml')
|
||||||
new=open(self.root_dir+'new.xml','r',encoding='utf-8').read()
|
newFeed=open(self.root_dir+'new.xml','r',encoding='utf-8')
|
||||||
new=re.sub(r'<lastBuildDate>.*?</lastBuildDate>','',new)
|
new=newFeed.read()
|
||||||
|
newFeed.cloes()
|
||||||
|
|
||||||
old=open(self.root_dir+'rss.xml','r',encoding='utf-8').read()
|
new=re.sub(r'<lastBuildDate>.*?</lastBuildDate>','',new)
|
||||||
old=re.sub(r'<lastBuildDate>.*?</lastBuildDate>','',old)
|
old=re.sub(r'<lastBuildDate>.*?</lastBuildDate>','',self.oldFeedString)
|
||||||
|
|
||||||
os.remove(self.root_dir+'new.xml')
|
os.remove(self.root_dir+'new.xml')
|
||||||
if new==old:
|
if new==old:
|
||||||
print("====== rss xml exist======")
|
print("====== rss xml no update ======")
|
||||||
|
feedFile=open(self.root_dir+'rss.xml',"w")
|
||||||
|
feedFile.write(self.oldFeedString)
|
||||||
|
feedFile.cloes()
|
||||||
return
|
return
|
||||||
|
|
||||||
print("====== create rss xml ======")
|
print("====== create rss xml ======")
|
||||||
@ -330,6 +335,10 @@ if not os.path.exists("blogBase.json"):
|
|||||||
print("blogBase is not exists, runAll")
|
print("blogBase is not exists, runAll")
|
||||||
blog.runAll()
|
blog.runAll()
|
||||||
else:
|
else:
|
||||||
|
if os.path.exists(blog.root_dir+'rss.xml'):
|
||||||
|
oldFeedFile=open(blog.root_dir+'rss.xml','r',encoding='utf-8')
|
||||||
|
blog.oldFeedString=oldFeed.read()
|
||||||
|
oldFeedFile.close()
|
||||||
if options.issue_number=="0" or options.issue_number=="":
|
if options.issue_number=="0" or options.issue_number=="":
|
||||||
print("issue_number=='0', runAll")
|
print("issue_number=='0', runAll")
|
||||||
blog.runAll()
|
blog.runAll()
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user