#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re, os, sys
D=os.path.dirname(os.path.abspath(__file__))
def rss(path):
    if not os.path.exists(path): return []
    s=open(path,encoding='utf-8',errors='ignore').read()
    out=[]
    for it in re.findall(r'<item>(.*?)</item>',s,flags=re.S):
        t=re.search(r'<title>(.*?)</title>',it,flags=re.S)
        p=re.search(r'<pubDate>(.*?)</pubDate>',it,flags=re.S)
        src=re.search(r'<source[^>]*>(.*?)</source>',it,flags=re.S)
        if t: out.append((t.group(1), p.group(1) if p else '', src.group(1) if src else ''))
    return out
for f in sys.argv[1:]:
    print(f"===== {f} =====")
    for t,p,s in rss(os.path.join(D,f)):
        print(f"  [{p[:16]}] {s}: {t[:150]}")
