Пример #1
0
    def getrss(self, n=10):
        items = self.rssitems(n)
        config = Configuration()

        image = PyRSS2Gen.Image(
            url=config.feed['default_logo_url'],
            title=config.feed['title'],
            link=config.feed['about_url'],
            description=u"%s\n\nLogo: %s" % (
                config.feed['description'],
                config.feed['logo_copyright']
            )
        )

        channel = ItunesRSS(
            title=self.title,
            link=self.link,
            description=self.description,
            language=self.language,
            generator=self.generator,
            lastBuildDate=dt.datetime.now(),
            items=items,
            image=image
        )

        return channel
Пример #2
0
def buildFeed(entries,output):
    entries.sort(key = lambda t:t[3],reverse=True)
    items = []
    for e in entries:
        items.append(PyRSS2Gen.RSSItem(
             title = e[0],
             link = e[1],
             pubDate=e[3],
             enclosure = PyRSS2Gen.Enclosure(e[1],0, "video/mp4"),
             description = e[2]
             ))
    rss = PyRSS2Gen.RSS2(
        title='Daly News Dump',
        link='http://newspodcast.github.io/newspodcast/podcast.xml',
        description = 'Get your daly news!',
        lastBuildDate = datetime.datetime.now(),
        image=PyRSS2Gen.Image("http://icons.iconarchive.com/icons/pelfusion/long-shadow-ios7/1024/News-icon.png", "Logo", "http://icons.iconarchive.com/icons/pelfusion/long-shadow-ios7/1024/News-icon.png",
                            1024, 1024, "awsome logo"),
        pubDate = datetime.datetime.now(),
        items = items
    )
    rss.write_xml(open(output, "w"))
    f = open(output,"r")
    xml = xl.parse(f)
    result = xml.toprettyxml()
    f.close()
    with open(output,"wb") as f:
        f.write(result.encode("utf-8"))
Пример #3
0
    def _create_image_tag(self, rssitem):
        logo_url = self._get_logo_url(rssitem.author)
        link_url = self._get_link_url(rssitem.author)
        config = Configuration()

        if logo_url is not None:
            return PyRSS2Gen.Image(
                url=logo_url,
                title=rssitem.author,
                link=link_url
            )
        else:
            return PyRSS2Gen.Image(
                url=config.feed['default_logo_url'],
                title=rssitem.author,
                link=link_url
            )
Пример #4
0
 def __write__(self):
     rss = PaicemanaFeed(
         title="WeeklyOSM em Português do Brasil",
         link="http://www.openstreetmap.com.br/weeklyosm.xml",
         description=
         "Um resumo semanal de todas as coisas que acontecem no mundo do OpenStreetMap",
         lastBuildDate=datetime.datetime.now(),
         docs=None,
         image=PyRSS2Gen.Image(url=self.feed.feed.image.href,
                               title=self.feed.feed.image.title,
                               link=self.feed.feed.image.link,
                               width=self.feed.feed.image.width,
                               height=self.feed.feed.image.height),
         selflink="http://www.openstreetmap.com.br/weeklyosm.xml",
         items=self.__items_for_write__())
     rss.write_xml(open("weeklyosm.xml", "w"), encoding="utf-8")
Пример #5
0
def feed_to_rss(parsed_feed, title):
    items = [
            PyRSS2Gen.RSSItem(
                title = x.title,
                link = x.link,
                description = x.summary,
                author = x.author,
                enclosure = enclosure(x),
                guid = x.link,
                pubDate = datetime.datetime(
                    x.published_parsed.tm_year,
                    x.published_parsed.tm_mon,
                    x.published_parsed.tm_mday,
                    x.published_parsed.tm_hour,
                    x.published_parsed.tm_min,
                    x.published_parsed.tm_sec,
                    ))
                for x in parsed_feed.entries
                ]
    rss = PyRSS2Gen.RSS2(
            title = title,
            link = parsed_feed['feed'].get("link"),
            description = parsed_feed['feed'].get("description"),

            language = parsed_feed['feed'].get("language"),
            copyright = parsed_feed['feed'].get("copyright"),
            managingEditor = parsed_feed['feed'].get("managingEditor"),
            webMaster = parsed_feed['feed'].get("webMaster"),
            pubDate = parsed_feed['feed'].get("pubDate"),
            lastBuildDate = parsed_feed['feed'].get("lastBuildDate"),
            image = PyRSS2Gen.Image(  # todo: use item image
                url = parsed_feed.entries[0].image.href,
                title = title,
                link = parsed_feed['feed'].get("image").get("link"),
                ),
            categories = parsed_feed['feed'].get("categories"),
            generator = parsed_feed['feed'].get("generator"),
            docs = parsed_feed['feed'].get("docs"),

            items = items
            )
    return rss
Пример #6
0
    def __init__(self, base_url, path, items):
        """
        Override PyRSS2Gen.RSS2 constructor
        - to simplify constructor args for user
        - to have custom namespaces
        """
        super().__init__(
            title=path,
            link=path,
            lastBuildDate=datetime.datetime.now(),
            items=items,
            description="",
            image=PyRSS2Gen.Image(base_url + "/feedIcon.png", path, path)
        )

        self.base_url=base_url
        self.rss_attrs["xmlns:itunes"] = "http://www.itunes.com/dtds/podcast-1.0.dtd"
        self.rss_attrs["xmlns:atom"] = "http://www.w3.org/2005/Atom"
        self.rss_attrs["xmlns:media"] = "http://search.yahoo.com/mrss/"
        self.rss_attrs["xmlns:dcterms"] = "http://purl.org/dc/terms/"
Пример #7
0
    "This is a test",
    "http://www.dalkescientific.com/",
    "To be or not to be.  That is the question.",

    language = "en-US",
    copyright = "Copyright (c) 2003, by me",
    managingEditor = "here@there (everywhere)",
    webMaster = "Spider Man",
    pubDate = datetime.datetime(2000, 11, 20, 23, 45, 19),
    lastBuildDate = datetime.datetime(2001, 12, 25, 22, 51, 49),
    categories = ["live", "love", "larf", "loaf"],

    cloud = PyRSS2Gen.Cloud("rpc.sys.com", 80, "/RPC2", "pingMe", "soap"),
                       
    ttl = 10,
    image = PyRSS2Gen.Image("http://there/", "THERE!", "link?",
                            25, 94, "some description"),
    rating = "For all audiences",

    textInput = PyRSS2Gen.TextInput("Qwerty", "Shrdlu", "Etaoin",
                                    "http://some/link"),
    skipDays = PyRSS2Gen.SkipDays(["Monday", "Thursday"]),
    skipHours = PyRSS2Gen.SkipHours([0, 5, 22]),

    items = [PyRSS2Gen.RSSItem(
                "Chapter 1", "http://xe.com/",
                "How to convert money.",
                author = "x@xe",
                # categories
                comments = "http://slashdot.org",
                # enclosure
                guid = "http://asdfghjk/",
Пример #8
0
def generateRSS( rootNode, indent=2 ):
    """Generate an OPML/XML tree from OutlineNode rootNode.
    
    parameters:
     filepath - unused since file writing has been factored out
     indent   - if > 0 indent with indent spaces per level
    return
     etree.Element of rootNode
    """

    valid_RSSChannel = ( "title", "link", "description", "language",
            "copyright", "managingEditor", "webMaster", "pubDate",
            "lastBuildDate", "categories", "generator", "docs",
            "cloud", "ttl", "image", "rating", "textInput",
            "skipHours", "skipDays", "items")

    valid_RSSItems = ( "title", "link", "description", "author",
            "categories", "comments", "enclosure", "guid",
            "pubDate", "source" )

    backTranslator = {
        'subtitle': 'description',
        'title': 'title',
        'published': 'pubDate',
        'id': 'guid'
    }

    now = str(datetime.datetime.now())
    now = now[:19]
    now = now.replace(" ", "_")

    # unused
    creator = CactusVersion.document_creator + " on %s." % (now,)

    # defaults
    head_d = {
        'title': "No Channel Title",
        'description': "No Channel description.",
        'link':  ""}

    headOP = rootNode.findFirstChildWithName_( "head" )

    if headOP:
        for headsub in headOP.children:
            name = headsub.name
            name = backTranslator.get(name, name)
            if name in valid_RSSChannel:
                value = headsub.getValueDict()
                if name == 'cloud':
                    cloud = PyRSS2Gen.Cloud(
                            value.get('domain', ""),
                            value.get('port', ""),
                            value.get('path', ""),
                            value.get('registerProcedure', ""),
                            value.get('protocol', ""))
                    head_d[ 'cloud' ] = cloud
                elif name == 'image':
                    image = PyRSS2Gen.Image(
                            value.get('href', ""),
                            value.get('title', ""),
                            value.get('link', ""),
                            value.get('width', None),
                            value.get('height', None),
                            value.get('description', None))
                    head_d[ 'image' ] = image

                else:
                    if len(value) == 1:
                        head_d[name] = value.values()[0]
                    else:
                        
                        head_d[name] = value
        print "HEAD:"
        pp(head_d)
    body_l = []
    bodyOP = rootNode.findFirstChildWithName_( "body" )

    if bodyOP:
        for bodysub in bodyOP.children:
            name = bodysub.name
            value = bodysub.getValueDict()
            d = {'title': "No Item Title",
                 'description': "No Item description."}

            for key in value:
                v = value[key]
                k = backTranslator.get(key, key)
                if k == "summary":
                    k = "description"
                if k in valid_RSSItems:

                    if k == 'enclosure':
                        url, rest = value[key].split('<<<')
                        length, type_ = rest.split(';', 1)
                        try:
                            length = int(length)
                        except ValueError, err:
                            if kwlog:
                                print "BOGUS ENCLOSURE LENGTH: %s" % repr(length)
                            length = 0
                        enc = PyRSS2Gen.Enclosure( url, length, type_)
                        d[k] = enc
                    else:
                        # TODO: check for type here; dicts and lists may be bad
                        d[ k ] = v #value[key]
                        if type(d[ k ]) in (list, dict, tuple):
                            print "\ngenerateRSS() type error.\n"
                        
            #print "ITEM:"
            #pp( d )
            body_l.append( PyRSS2Gen.RSSItem( **d ) )
Пример #9
0
    def FromConfig(klass, cp):
        if not cp.has_section('Feed'):
            print "ERROR: no Feed section present in config file"
            return None

        if cp.has_option('Feed', 'skiphours'):
            skipHours = eval("PyRSS2Gen.SkipHours([ %s ])" %
                             cp.get('Feed', 'skiphours'))
        else:
            skipHours = None

        if cp.has_option('Feed', 'skipdays'):
            skipDays = eval("PyRSS2Gen.SkipDays([ %s ])" %
                            cp.get('Feed', 'skipdays'))
        else:
            skipDays = None

        if cp.has_section('Feed/Image'):
            image = PyRSS2Gen.Image(
                url=eval(cp.get('Feed/Image', 'url')),
                title=eval(cp.get('Feed/Image', 'title', dne='None')),
                description=eval(
                    cp.get('Feed/Image', 'description', dne='None')),
                link=eval(cp.get('Feed/Image', 'link', dne='None')),
                width=eval(cp.get('Feed/Image', 'width', dne='None')),
                height=eval(cp.get('Feed/Image', 'height', dne='None')),
            )
        else:
            image = None

        customEltDefList = []
        if cp.has_section('Feed/CustomElements'):
            for ceItem in cp.items('Feed/CustomElements'):
                tup = eval(ceItem[1])
                ce = CustomEltDef(configTuple=tup)
                customEltDefList.append(ce)
        else:
            customEltDefList = None

        # TODO: Integrate ESML formatting here
        format = None

        rss = klass(
            title=eval(cp.get('Feed', 'title')),
            link=eval(cp.get('Feed', 'link')),
            description=eval(cp.get('Feed', 'description')),
            channelUID=eval(cp.get('Feed', 'channeluid', dne='"default"')),
            dataSource=eval(cp.get('Feed', 'datasource', dne='None')),
            language=eval(cp.get('Feed', 'language', dne='None')),
            copyright=eval(cp.get('Feed', 'copyright', dne='None')),
            managingEditor=eval(cp.get('Feed', 'managingeditor', dne='None')),
            webMaster=eval(cp.get('Feed', 'webmaster', dne='None')),
            rating=eval(cp.get('Feed', 'rating', dne='None')),
            ttl=eval(cp.get('Feed', 'ttl', dne='None')),
            skipHours=skipHours,
            skipDays=skipDays,
            image=image,
            format=format,
            customEltDefList=customEltDefList,
        )
        return rss
Пример #10
0
	temp_item = PyRSS2Gen.RSSItem(
		title = program["name"],
		link = 	program_url+str(program["id"]),
		description = program["description"],
		pubDate = datetime.datetime.fromtimestamp(int(int(program["createTime"])/1000)),
		guid = "netease_"+str(program["id"]),
		enclosure = PyRSS2Gen.Enclosure(
			url = audio_url+str(program["mainSong"]["id"])+".mp3",
			length = program["mainSong"]["bMusic"]["size"],
			type = "audio/mpeg"
			)
		)
	item_list.append(temp_item);

rss = PyRSS2Gen.RSS2(  
	title = info["name"],  
	link = radio_url+radio_id,  
	description = info["desc"], 
	language = "zh_CN",
	image = PyRSS2Gen.Image(
		url = info["picUrl"],
		title = info["name"],
		link = radio_url+radio_id
	),
	pubDate = datetime.datetime.fromtimestamp(int(int(info["lastProgramCreateTime"])/1000)),
	lastBuildDate = datetime.datetime.now(),
	items = item_list
)

rss.write_xml(open(radio_id+".xml", "w",encoding='utf-8'),encoding='utf-8')
Пример #11
0
            type = "audio/mpeg",
            length = 0
        ),
        guid = orig_url,
        pubDate = info_time
    ))

    print("Episode: " + title)

rss = PyRSS2Gen.RSS2(
    title = "YouTube",
    link = "",
    description = "",
    image = PyRSS2Gen.Image(
        url = "https://via.placeholder.com/720/272727/f00?text=YT",
        title = "YouTube",
        link = ""
    ),
    items = episodes,
)

with open(os.path.join(DIR, "feed.xml"), "w", encoding = "utf-8") as f:
    rss.write_xml(f, encoding="utf-8")

for path in trash:
    try:
        os.unlink(path)
        print("Deleted: " + path)
    except:
        print("Cannot delete: " + path)
Пример #12
0
        post_description_html = post_soup.find('div', attrs={'class': 'entry'})

        post_description_html.find(('div'), attrs={'class': 'podPress_content'}).decompose()
        post_description = bleach.clean(str(post_description_html),
                                        tags=['a', 'abbr', 'acronym', 'b', 'blockquote', 'code',
                                              'em', 'i', 'li', 'ol', 'strong', 'ul', 'p'],
                                        strip=True).strip()

        podcast_feed.append((post_title, post_audio, post_description, post_date, post_permlink))

rss = PyRSS2Gen.RSS2(
    title='Unofficial Zomia ONE Premium Feed',
    link='https://zomia.podbean.com/',
    image=PyRSS2Gen.Image('https://pbcdn1.podbean.com/imglogo/ep-logo/pbblog4172212/zomiaoneunderground.jpg',
                          'Unofficial Zomia ONE Premium Feed',
                          'https://zomia.podbean.com/',
                          '144',
                          '144',
                          'Unofficial Zomia ONE Premium Feed'),

    description='This is an unofficial RSS feed for zomia.podbean.com which, unlike the Official RSS feed, only '
                'includes premium content. For more information, visit https://github.com/srosorcxisto/zomiaonescraper ' 
                'This feedis completely unofficial and not connected in any way to the Zomia ONE network.',
    lastBuildDate=datetime.now())

rss_post = []
for post in podcast_feed:
    rss.items.append(PyRSS2Gen.RSSItem(
        title=post[0],
        link=post[1],
        description=post[2],
        guid=post[4],
import datetime
import PyRSS2Gen as RSS2

FEED_DATA = {
    'title': 'Sunday Puzzle',
    'link':  'https://npr.org/puzzle',
    'description': "The Weekly Quiz from NPR Puzzlemaster Will Shortz",

    'lastBuildDate': datetime.datetime.now(),

    'image': RSS2.Image(
        url = 'https://willshortz.com/images/Shortz_Will.jpg',
        title = 'Will Shortz',
        link  = 'https://npr.org/puzzle'
    ),

    'ttl': 24*60,
    'language': 'en-US',
    'generator': None,
    'docs': None,
}

def feed(items, data=FEED_DATA):
    return RSS2.RSS2(
        **data,
        items = [RSS2.RSSItem(
            title = i['title'],
            link  = i['link'],
            description = i['description'],
            guid  = RSS2.Guid(i['guid']),
            enclosure = RSS2.Enclosure(url=i['file'], type='audio/mpeg', length=i['bytes']),
Пример #14
0
def rss():
    monitorings = Monitoring.query.get_for_home()

    rss_items = []

    for monitoring in monitorings:
        title = ''
        description = ''

        if monitoring.status == MonitoringStatus.DOWN:
            title = _('%(monitoring_name)s is down',
                      monitoring_name=monitoring.name)
            description = _(
                '<p><b>%(monitoring_name)s</b> seems to encounter issues and is unreachable since the <b>%(last_status_change)s</b>. The reason is:</p><p>%(last_down_reason)s</p>',
                monitoring_name=monitoring.name,
                last_status_change=format_datetime(
                    monitoring.last_status_change_at.datetime, 'short'),
                last_down_reason=monitoring.last_down_reason)
        elif monitoring.status == MonitoringStatus.UP:
            title = _('%(monitoring_name)s is up',
                      monitoring_name=monitoring.name)
            description = _(
                '<p><b>%(monitoring_name)s</b> is up and reachable since the <b>%(last_status_change)s</b>.</p>',
                monitoring_name=monitoring.name,
                last_status_change=format_datetime(
                    monitoring.last_status_change_at.datetime, 'short'))
        elif monitoring.status == MonitoringStatus.UNKNOWN:
            title = _('%(monitoring_name)s status is unknown',
                      monitoring_name=monitoring.name)
            description = _(
                '<p>The status of <b>%(monitoring_name)s</b> is currently unknown.</p>',
                monitoring_name=monitoring.name)

        date = monitoring.last_status_change_at if monitoring.last_status_change_at else monitoring.created_at

        rss_items.append(
            PyRSS2Gen.RSSItem(title=title,
                              link=monitoring.url,
                              description=description,
                              guid=PyRSS2Gen.Guid(':'.join([
                                  str(monitoring.id), monitoring.status.value,
                                  date.format()
                              ]),
                                                  isPermaLink=False),
                              pubDate=date.datetime,
                              categories=[monitoring.status.value]))

    rss = PyRSS2Gen.RSS2(title=_('%(title)s - Monitorings status',
                                 title=app.config['TITLE']),
                         link=url_for('home', _external=True),
                         description=_('%(title)s - Monitorings status',
                                       title=app.config['TITLE']),
                         language=g.CURRENT_LOCALE,
                         image=PyRSS2Gen.Image(
                             url_for('static',
                                     filename='images/logo.png',
                                     _external=True),
                             _('%(title)s - Monitorings status',
                               title=app.config['TITLE']),
                             url_for('home', _external=True)),
                         lastBuildDate=arrow.now().datetime,
                         items=rss_items)

    return Response(rss.to_xml(encoding='utf-8'),
                    mimetype='application/rss+xml')
Пример #15
0
        else:
            #print("No subject")
            description_string = "%s %s." % (obj['description'], obj['location'])
        item = PodcastItem(
                title=obj['title'],
                link=obj['audio_link'],
                description=description_string,
                guid=obj['id'],
                pubDate=obj['date'],
                duration=obj['duration'],
            )
        parsed_items.append(item)

rss = PodcastRSS(
    title="SJC Friday Night Lectures",
    link="http://digitalarchives.sjc.edu/items/browse?tags=Friday+night+lecture",
    description="Unofficial feed of the recordings of Friday Night Lectures at SJC.",

    lastBuildDate=datetime.datetime.now(),

    image=PyRSS2Gen.Image(
            url='https://diplomaclassics.com/images/Entities/insignia/v2/SjcaSealOrangeGold_220.png',
            title='SJC Logo',
            link='https://diplomaclassics.com/images/Entities/insignia/v2/SjcaSealOrangeGold_220.png',
        ),

    items=parsed_items
    )

rss.write_xml(open("pyrss2gen.xml", "w", encoding='utf-8'))
Пример #16
0
 def publish_extensions(self, handler):
     """
      Override to set values of various itunes xmlns tags
      """
     if self.enclosure.url.endswith(".mp3"):
         PyRSS2Gen._element(handler, "image", PyRSS2Gen.Image(self.enclosure.url + ".png", self.title, self.link))