import project from david with uv

This commit is contained in:
Abel Luck 2026-02-20 10:07:49 +01:00
commit 8056704736
11 changed files with 1530 additions and 0 deletions

55
pygea/main.py Normal file
View file

@ -0,0 +1,55 @@
"""Pygea main entry point"""
import hashlib
from pygea.pangeafeed import PangeaFeed
from pygea.pexception import PangeaServiceException
def main():
# Feeds are generated for a single, specified, domain
domain = 'www.martinoticias.com'
args = {
# tuple values:
# [0] category name or a string representing a content query
# [1] only the newest content desired (as configured in pygea.ini)?
# [2] special content_type for this category only (from the approved list of types)
'categories': [
('Titulares',True, None),
('Cuba', True, None),
('América Latina', True, None),
('Info Martí ', False, None), # YES! this category name has a space character at the end!
('Noticiero Martí Noticias', True, None)
],
'default_content_type': "articles"
}
# TWO OPTIONS from the args defined above:
# 1. Generate a single feed from the defined categories
#try:
# pf = PangeaFeed(domain, args)
# pf.acquire_content()
# pf.generate_feed()
# pf.disgorge()
#except PangeaServiceException as error:
# print(error)
# 2. Generate different feeds for each defined category
try:
for cat_tuple in args['categories']:
# form new args for each category/query
newargs = {
'categories': [cat_tuple],
'default_content_type': "articles"
}
pf = PangeaFeed(domain, newargs)
pf.acquire_content()
pf.generate_feed()
# put each feed into a different sub-directory
feed_subdir = hashlib.md5(cat_tuple[0].encode('utf-8')).hexdigest()[:7]
pf.disgorge(feed_subdir)
print("feed for {} output to sub-directory {}".format(cat_tuple[0], feed_subdir))
except PangeaServiceException as error:
print(error)
if __name__ == "__main__":
main()