fixing yt + crashes + failsafe
This commit is contained in:
23
xboxsyde.py
Normal file
23
xboxsyde.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import feedparser
|
||||
import io
|
||||
import html
|
||||
import datetime
|
||||
import requests
|
||||
import time
|
||||
|
||||
url = r'https://www.xboxygen.com/spip.php?page=backend'
|
||||
|
||||
html_text = requests.get(url).text
|
||||
news = feedparser.parse(html_text)
|
||||
|
||||
yesterday_6am = datetime.datetime.now(datetime.timezone.utc).replace(hour=6, minute=0, second=0, microsecond=0) - datetime.timedelta(days=1)
|
||||
|
||||
try:
|
||||
new_posts = [entry for entry in news.entries if datetime.datetime.strptime(entry.published.replace('GMT', '+0000'), '%a, %d %b %Y %H:%M:%S %z') > yesterday_6am]
|
||||
|
||||
except:
|
||||
new_posts = [entry for entry in news.entries if datetime.datetime.fromtimestamp(time.mktime(entry.updated_parsed)).replace(tzinfo=datetime.timezone.utc) > yesterday_6am]
|
||||
#else if
|
||||
#entry.updated.replace('GMT', '+0000'), '%a, %d %b %Y %H:%M:%S %z'
|
||||
|
||||
print(new_posts)
|
||||
Reference in New Issue
Block a user