Compare commits

..

No commits in common. "main" and "master" have entirely different histories.
main ... master

2 changed files with 12 additions and 32 deletions

View File

@ -58,8 +58,7 @@ def create_extract(txt):
def parse_feeds(weeks, username, blog):
feedparser.USER_AGENT = "IronBloggerBot/0.2 +http://ironblogger.de/"
uri = blog['feed']
print("Retreiving ", uri)
uri = blog[3]
feed = feedparser.parse(uri)
if not feed.entries:
@ -83,33 +82,25 @@ def parse_feeds(weeks, username, blog):
if post['url'] not in [p['url'] for p in weeks[key]]:
weeks[key].append(post)
# -- main
config=settings.load_settings()
if os.path.exists('data'):
shutil.rmtree('data')
gitrepo = Repo.clone_from('https://git.wazong.de/iron-blogger/test.git', 'data')
gitrepo = Repo.clone_from('https://git.wazong.de/iron-blogger/content-society.git', 'data')
try:
with open('data/blogs.yaml') as f:
users = yaml.safe_load(f.read())
except FileNotFoundError:
users = []
print(users)
with open('data/bloggers.yml') as f:
users = yaml.safe_load(f.read())
if not os.path.exists('data/out'):
os.makedirs('data/out')
try:
with open('data/out/report.yaml') as f:
with open('data/out/report.yml') as f:
log = yaml.safe_load(f.read())
except FileNotFoundError:
except IOError:
log = {}
# START = datetime.datetime.strptime(config['start_date'],'%Y/%m/%d')
START = datetime.datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) - datetime.timedelta(days=7)
START = datetime.datetime.strptime(config['start_date'],'%Y/%m/%d')
if len(sys.argv) > 1:
for username in sys.argv[1:]:
@ -123,18 +114,8 @@ else:
if enddate < datetime.datetime.now():
print("User inactive: ", username)
continue
for l in u['blogs']:
for l in u['links']:
parse_feeds(log, username, l)
with open('data/out/report.yaml', 'w') as f:
with open('data/out/report.yml', 'w') as f:
yaml.safe_dump(log, f)
gitrepo.index.add(['out/report.yaml'])
with open('data/blogs.yaml', 'w') as f:
yaml.safe_dump(users, f)
gitrepo.index.add(['blogs.yaml'])
print(gitrepo.index.diff(gitrepo.head.commit))
# gitrepo.index.commit('autocommit')
# gitrepo.remotes.origin.push()

View File

@ -4,14 +4,13 @@ import configparser, os
def load_settings():
configfile = configparser.ConfigParser()
configfile.read('settings.cfg')
config=dict()
config['mail']=configfile.get("general","mail")
config['report_interval']=configfile.get("general","report_interval", fallback="weekly")
config['start_date']=configfile.get("general","start_date")
config['username']=configfile.get("blogsettings","username")
config['password']=configfile.get("blogsettings","password", fallback="")
config['password']=configfile.get("blogsettings","password")
config['xmlrpc_endpoint']=configfile.get("blogsettings","xmlrpc_endpoint")
config['blog_id']=configfile.get("blogsettings","blog_id", fallback="0")
config['blog_id']=configfile.get("blogsettings","blog_id")
config['participants_page_id']=configfile.get("blogsettings","participants_page_id")
return config