Add podcast

This commit is contained in:
Niklas Mollenhauer
2014-09-20 10:10:07 +02:00
parent c7c896884b
commit 771eca0e7d
2 changed files with 136 additions and 0 deletions
+56
View File
@@ -0,0 +1,56 @@
///<reference path="podcast.d.ts" />
import Podcast = require('podcast');
/* lets create an rss feed */
var feed = new Podcast({
title: 'title',
description: 'description',
feed_url: 'http://example.com/rss.xml',
site_url: 'http://example.com',
image_url: 'http://example.com/icon.png',
docs: 'http://example.com/rss/docs.html',
author: 'Dylan Greene',
managingEditor: 'Dylan Greene',
webMaster: 'Dylan Greene',
copyright: '2013 Dylan Greene',
language: 'en',
categories: ['Category 1','Category 2','Category 3'],
pubDate: new Date('May 20, 2012 04:00:00 GMT'),
ttl: 60,
itunesAuthor: 'Max Nowack',
itunesSubtitle: 'I am a sub title',
itunesSummary: 'I am a summary',
itunesOwner: { name: 'Max Nowack', email:'max@unsou.de' },
itunesExplicit: false,
itunesCategory: {
"name": "Entertainment",
"subcats": null
},
itunesImage: 'http://link.to/image.png'
});
/* loop over data and add to feed */
feed.item({
title: 'item title',
description: 'use this for the content. It can include html.',
url: 'http://example.com/article4?this&that', // link to the item
guid: '1123', // optional - defaults to url
categories: ['Category 1','Category 2','Category 3','Category 4'], // optional - array of item categories
author: 'Guest Author', // optional - defaults to feed author property
date: new Date('May 27, 2012'),
lat: 33.417974, //optional latitude field for GeoRSS
long: -111.933231, //optional longitude field for GeoRSS
enclosure : {url:'...', file:'path-to-file'}, // optional enclosure
itunesAuthor: 'Max Nowack',
itunesExplicit: false,
itunesSubtitle: 'I am a sub title',
itunesSummary: 'I am a summary',
itunesDuration: 12345,
itunesKeywords: ['javascript','podcast']
});
// cache the xml to send to clients
var xml = feed.xml();
console.log(xml);
+80
View File
@@ -0,0 +1,80 @@
// Type definitions for podcast v0.1.0
// Project: http://github.com/maxnowack/node-podcast
// Definitions by: Niklas Mollenhauer <https://github.com/nikeee>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface PodcastStatic
{
new(options: IFeedOptions): PodcastStatic;
item(options: IItemOptions): void;
xml(indent?: string): string;
}
interface IFeedOptions
{
title: string;
description?: string;
generator?: string;
feed_url: string;
site_url: string;
image_url?: string;
docs?: string;
author: string;
managingEditor?: string;
webMaster?: string;
copyright?: string;
language?: string;
categories?: string[];
pubDate?: Date;
ttl?: number;
itunesAuthor?: string;
itunesSubtitle?: string;
itunesSummary?: string;
itunesOwner?: IItunesOwner;
itunesExplicit?: boolean;
itunesCategory?: IItunesCategory;
itunesImage?: string;
}
interface IItunesOwner
{
name: string;
email: string;
}
interface IItunesCategory
{
name: string;
subcats: IItunesSubCategory[]
}
interface IItunesSubCategory
{
name: string;
subcat: string[] /* ? */
}
interface IItemOptions
{
title: string;
description: string;
url: string;
guid: string;
categories?: string[];
author?: string;
date: Date;
lat?: number;
long?: number;
itunesAuthor?: string;
itunesExplicit?: boolean;
itunesSubtitle?: string;
itunesSummary?: string;
itunesDuration?: number;
itunesKeywords?: string[];
}
declare var Podcast: PodcastStatic;
declare module "podcast"
{
export = Podcast;
}