Пример #1
0
def generate_podcast_xml(base, books):
    from podgen import Podcast, Episode
    from datetime import timedelta
    from podgen import Media

    p = Podcast()

    p.name = "AeonNeo's Audiobooks"
    p.description = "Description"
    p.website = "www.yangvincent.com"
    p.explicit = False

    # create episode
    for book_name in books:
        ep = Episode()
        ep.title = book_name[:-4]
        full_path = base + '/files/' + book_name
        dev_path = 'files/' + book_name
        try:
            book_size = os.path.getsize(dev_path)
        except OSError as e:
            print(e)
            book_size = 0

        ep.media = Media(full_path, type='audio/mp4a', size=book_size)
        p.episodes.append(ep)

    # Generate rss
    p.rss_file('skeleton/rss.xml', minimize=True)
Пример #2
0
    def test_title(self):
        ep = Episode()

        def get_element():
            return ep.rss_entry().find("title")
        # Starts out as None or empty.
        assert ep.title is None or ep.title == ""

        # We test that you cannot create RSS when it's empty or blank in
        # another method.

        # Test that it is set correctly
        ep.title = None
        assert ep.title is None

        ep.title = ""
        self.assertEqual(ep.title, "")

        # Test that the title is used correctly
        title = "My Fine Title"
        ep.title = title
        self.assertEqual(ep.title, title)

        element = get_element()
        assert element is not None
        self.assertEqual(element.text, title)
Пример #3
0
    def test_title(self):
        ep = Episode()

        def get_element():
            return ep.rss_entry().find("title")

        # Starts out as None or empty.
        assert ep.title is None or ep.title == ""

        # We test that you cannot create RSS when it's empty or blank in
        # another method.

        # Test that it is set correctly
        ep.title = None
        assert ep.title is None

        ep.title = ""
        self.assertEqual(ep.title, "")

        # Test that the title is used correctly
        title = "My Fine Title"
        ep.title = title
        self.assertEqual(ep.title, title)

        element = get_element()
        assert element is not None
        self.assertEqual(element.text, title)
Пример #4
0
    def test_idIsSet(self):
        guid = "http://example.com/podcast/episode1"
        episode = Episode()
        episode.title = "My first episode"
        episode.id = guid
        item = episode.rss_entry()

        assert item.find("guid").text == guid
Пример #5
0
    def test_idNotSetButEnclosureIsUsed(self):
        guid = "http://example.com/podcast/episode1.mp3"
        episode = Episode()
        episode.title = "My first episode"
        episode.media = Media(guid, 97423487, "audio/mpeg")

        item = episode.rss_entry()
        assert item.find("guid").text == guid
Пример #6
0
    def test_idNotSetButEnclosureIsUsed(self):
        guid = "http://example.com/podcast/episode1.mp3"
        episode = Episode()
        episode.title = "My first episode"
        episode.media = Media(guid, 97423487, "audio/mpeg")

        item = episode.rss_entry()
        assert item.find("guid").text == guid
Пример #7
0
    def test_idIsSet(self):
        guid = "http://example.com/podcast/episode1"
        episode = Episode()
        episode.title = "My first episode"
        episode.id = guid
        item = episode.rss_entry()

        assert item.find("guid").text == guid
Пример #8
0
    def test_idSetToFalseSoEnclosureNotUsed(self):
        episode = Episode()
        episode.title = "My first episode"
        episode.media = Media("http://example.com/podcast/episode1.mp3",
                            34328731, "audio/mpeg")
        episode.id = False

        item = episode.rss_entry()
        assert item.find("guid") is None
Пример #9
0
def main():
    with open('thebugle.json') as f:
        episodes = json.load(f)

    p = Podcast(
        name="TimesOnLine Bugle Archive",
        description="Old Bugle episodes, podcast feed",
        website="https://www.thebuglepodcast.com/",
        explicit=False,
    )

    for episode in episodes:
        ep = p.add_episode(
            Episode(title=f"{episode['id']}: {episode['title']}"))
        ep.media = Media.create_from_server_response(
            f"{MEDIA_BASE_URL}/{episode['file']}")

        ep.media.fetch_duration()

        date = episode['date'].split('-')
        ep.publication_date = datetime(int(date[0]),
                                       int(date[1]),
                                       int(date[2]),
                                       0,
                                       0,
                                       0,
                                       tzinfo=pytz.utc)

    print(p.rss_str())
Пример #10
0
def rss(url_token):
    dropbox_access_token, title, description = get_the_latest_token_info(
        url_token)
    urls = get_temporary_link(dropbox_access_token)
    p = Podcast()
    p.name = title
    p.description = description
    p.website = "https://www.google.com"
    p.explicit = True

    for i, (size, url, uid, name) in enumerate(urls):
        my_episode = Episode()
        my_episode.title = os.path.splitext(name)[0]
        my_episode.id = uid
        my_episode.media = Media(url, size=size, type="audio/mpeg")
        p.episodes.append(my_episode)
    return Response(str(p), mimetype='text/xml')
def genero_feed(puntateList):
    if puntateList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "Il Ruggito del Coniglio"
        p.description = "Il Ruggito del Coniglio, il programma cult di Radio 2 condotto da Marco Presta e Antonello Dose, racconta l'attualita con folgorante ironia."
        p.website = "http://www.raiplayradio.it/programmi/ilruggitodelconiglio/"
        p.explicit = True
        p.image = "https://rss.draghetti.it/ruggitodelconiglio_image.jpg"
        p.feed_url = "https://rss.draghetti.it/ruggitodelconiglio.xml"
        p.copyright = "Rai Radio 2"
        p.language = "it-IT"

        for puntata in puntateList:
            episode = Episode()

            episode.title = puntata[0].encode("ascii", "ignore")
            episode.link = puntata[1]

            # La dimensione del file e approssimativa
            episode.media = Media(puntata[3], puntata[4])

            if puntata[2]:
                episode.publication_date = datetime.datetime(int(puntata[2].split("/")[2]),
                                                             int(puntata[2].split("/")[1]),
                                                             int(puntata[2].split("/")[0]), 10,
                                                             00, tzinfo=pytz.utc)
            else:
                episode.publication_date = pytz.utc.localize(datetime.datetime.utcnow())

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #12
0
    def test_constructor(self):
        title = "A constructed episode"
        subtitle = "We're using the constructor!"
        summary = "In this week's episode, we try using the constructor to " \
                  "create a new Episode object."
        long_summary = "In this week's episode, we try to use the constructor " \
                       "to create a new Episode object. Additionally, we'll " \
                       "check whether it actually worked or not. Hold your " \
                       "fingers crossed!"
        media = Media("http://example.com/episodes/1.mp3", 1425345346,
                      "audio/mpeg",
                      datetime.timedelta(hours=1, minutes=2, seconds=22))
        publication_date = datetime.datetime(2016,
                                             6,
                                             7,
                                             13,
                                             37,
                                             0,
                                             tzinfo=pytz.utc)
        link = "http://example.com/blog/?i=1"
        authors = [Person("John Doe", "*****@*****.**")]
        image = "http://example.com/static/1.png"
        explicit = True
        is_closed_captioned = False
        position = 3
        withhold_from_itunes = True

        ep = Episode(
            title=title,
            subtitle=subtitle,
            summary=summary,
            long_summary=long_summary,
            media=media,
            publication_date=publication_date,
            link=link,
            authors=authors,
            image=image,
            explicit=explicit,
            is_closed_captioned=is_closed_captioned,
            position=position,
            withhold_from_itunes=withhold_from_itunes,
        )

        # Time to check if this works
        self.assertEqual(ep.title, title)
        self.assertEqual(ep.subtitle, subtitle)
        self.assertEqual(ep.summary, summary)
        self.assertEqual(ep.long_summary, long_summary)
        self.assertEqual(ep.media, media)
        self.assertEqual(ep.publication_date, publication_date)
        self.assertEqual(ep.link, link)
        self.assertEqual(ep.authors, authors)
        self.assertEqual(ep.image, image)
        self.assertEqual(ep.explicit, explicit)
        self.assertEqual(ep.is_closed_captioned, is_closed_captioned)
        self.assertEqual(ep.position, position)
        self.assertEqual(ep.withhold_from_itunes, withhold_from_itunes)
Пример #13
0
def index():
	'''https://podgen.readthedocs.io/en/latest/'''
	urls = get_temporary_link()
	p = Podcast()
	p.name = "ambience"
	p.description = "ambience"
	p.website = "LINK HERE"
	p.explicit = True	

	for i, (size, url) in enumerate(urls):
		my_episode = Episode()
		my_episode.title = "ambience music {}".format(i + 1)
		my_episode.media = Media(url,
								 size=size,
								 type="audio/mpeg")
		p.episodes.append(my_episode)

	rss = str(p)
	return Response(rss, mimetype='text/xml')
Пример #14
0
 def get_episode(self):
     media = Media(get_download_url(self.relative_path),
                   os.path.getsize(self.full_path),
                   duration=timedelta(seconds=self.duration_seconds))
     return Episode(title=self.title,
                    media=media,
                    summary=self.summary,
                    explicit=False,
                    image=self.image_url,
                    publication_date=self.publication_date,
                    subtitle=self.subtitle)
Пример #15
0
 def episode_from_filename(filename):
     info = get_file_info(filename)
     media_url = to_slug(filename)
     return Episode(
         title=filename,
         publication_date=info.get('created', datetime.now()),
         media=Media(
             os.path.join(config.SERVER_BASEURL, 'episodes', media_url),
             info.get('size'),
             None,  # type
             info.get('duration')))
Пример #16
0
def genero_feed(puntateList):
    if puntateList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "Pascal Rai Radio 2"
        p.description = "Pascal un programma di Matteo Caccia in onda su Radio2 che racconta storie di vita. Episodi grandi o piccoli, stravolgenti o minuti, momenti che hanno modificato per sempre la nostra vita o che, anche se di poco, l'hanno indirizzata. Storie che sono il termometro della temperatura di ognuno di noi e che in parte raccontano chi siamo. "
        p.website = "http://www.raiplayradio.it/programmi/pascal/"
        p.explicit = True
        p.image = "https://rss.draghetti.it/pascal_image.jpg"
        p.feed_url = "https://rss.draghetti.it/pascal.xml"
        p.copyright = "Rai Radio 2"
        p.language = "it-IT"

        for puntata in puntateList:
            episode = Episode()

            episode.title = puntata[0].encode("ascii", "ignore")
            episode.link = puntata[1]

            # La dimensione del file e approssimativa
            episode.media = Media(puntata[3], puntata[4])

            if puntata[2]:
                episode.publication_date = datetime.datetime(int(puntata[2].split("/")[2]),
                                                             int(puntata[2].split("/")[1]),
                                                             int(puntata[2].split("/")[0]), 20,
                                                             00, tzinfo=pytz.utc)
            else:
                episode.publication_date = pytz.utc.localize(datetime.datetime.utcnow())

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #17
0
def genero_feed(episodesList):
    if episodesList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "NECST Tech Time"
        p.description = "Feed Podcast non ufficiale di NECST Tech Time - Powered By Andrea Draghetti"
        p.website = "http://www.poliradio.it/podcast/programmi/34/necst-tech-time"
        p.explicit = True
        p.image = "https://rss.draghetti.it/necst_image.jpg"
        p.feed_url = "https://rss.draghetti.it/necstpodcast.xml"
        p.copyright = "Poli Radio"
        p.language = "it-IT"

        for episodedetails in episodesList:
            episode = Episode()

            episode.title = episodedetails[1].encode("ascii", "ignore")
            episode.link = episodedetails[2].encode("ascii", "ignore")

            # La dimensione e statistica in base alle puntante analizzate
            episode.media = Media(episodedetails[3],
                                  30000000,
                                  type="audio/x-m4a",
                                  duration=None)
            episode.publication_date = episodedetails[4]

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #18
0
def genero_feed(episodesList):
    if episodesList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "All You Can Dance by Dino Brawn"
        p.description = "Feed Podcast non ufficiale di All You Can Dance by Dino Brown - Powered By Andrea Draghetti"
        p.website = "https://onedance.fm/"
        p.explicit = True
        p.image = "https://rss.draghetti.it/allyoucandance_image.jpg"
        p.feed_url = "https://rss.draghetti.it/allyoucandance.xml"
        p.copyright = "One Dance"
        p.language = "it-IT"

        for episodedetails in episodesList:
            episode = Episode()

            episode.title = episodedetails[1].encode("ascii", "ignore")
            episode.link = episodedetails[2].encode("ascii", "ignore")

            # La dimensione e statistica in base alle puntante analizzate
            episode.media = Media(episodedetails[3], 30000000, type="audio/x-m4a", duration=None)
            episode.publication_date = episodedetails[4]

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #19
0
def genero_feed(puntateList):
    if puntateList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "Il Ruggito del Coniglio"
        p.description = "Il Ruggito del Coniglio, il programma cult di Radio 2 condotto da Marco Presta e Antonello Dose, racconta l'attualita con folgorante ironia."
        p.website = "http://www.raiplayradio.it/programmi/ilruggitodelconiglio/"
        p.explicit = True
        p.image = "https://rss.draghetti.it/ruggitodelconiglio_image.jpg"
        p.feed_url = "https://rss.draghetti.it/ruggitodelconiglio.xml"
        p.copyright = "Rai Radio 2"
        p.language = "it-IT"

        for puntata in puntateList:
            episode = Episode()

            episode.title = puntata[0].encode("ascii", "ignore")
            episode.link = puntata[1]

            # La dimensione del file e approssimativa
            episode.media = Media(puntata[3], puntata[4])

            if puntata[2]:
                episode.publication_date = datetime.datetime(int(puntata[2].split("/")[2]),
                                                             int(puntata[2].split("/")[1]),
                                                             int(puntata[2].split("/")[0]), 10,
                                                             00, tzinfo=pytz.utc)
            else:
                episode.publication_date = pytz.utc.localize(datetime.datetime.utcnow())

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #20
0
def genero_feed(episodesList):
    if episodesList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "NECST Tech Time"
        p.description = "The NECSTLab (Novel, Emerging Computing System Technologies Laboratory) is a laboratory inside DEIB department of Politecnico di Milano, where there are a number of different research lines on advanced topics in computing systems: from architectural characteristics, to hardware-software codesign methodologies, to security and dependability issues of complex system architectures (scaling from mobile devices to large virtualized datacenters)."
        p.website = "http://www.poliradio.it/podcast/programmi/34/necst-tech-time"
        p.explicit = True
        p.image = "https://rss.draghetti.it/necst_image.jpg"
        p.feed_url = "https://rss.draghetti.it/necstpodcast.xml"
        p.copyright = "Poli Radio"
        p.language = "it-IT"

        for episodedetails in episodesList:
            episode = Episode()

            episode.title = episodedetails[1].encode("ascii", "ignore")
            episode.link = episodedetails[2].encode("ascii", "ignore")

            # La dimensione e statistica in base alle puntante analizzate
            episode.media = Media(episodedetails[3], 30000000, type="audio/x-m4a", duration=None)
            episode.publication_date = episodedetails[4]

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #21
0
def rssfeed(request, programid):
    """ Builds the rss feed for a program identified by it's id. (int)

    1. Fetches all episodes of the program from the digas db.
    2. gets the programinfo from the app db
    3. Uses podgen to do the actual XML-generation.
    """
    podcasts = DigasPodcast.objects.using('digas').filter(
        softdel=0,
        program=int(programid)).only('program', 'title', 'remark', 'author',
                                     'createdate', 'broadcastdate', 'filename',
                                     'filesize', 'duration',
                                     'softdel').order_by('-createdate')
    programinfo = ProgramInfo.objects.get(programid=int(programid))

    # loading globalsettings here, and not at the module_level
    # This way django won't explode because of missing
    # constance_config table when we start on scratch
    # or set up in a new environment.
    from .models import globalsettings

    p = Podcast(
        name=programinfo.name,
        subtitle=programinfo.subtitle,
        description=programinfo.description,
        website=feed_url(programid),  # programinfo.website,
        explicit=programinfo.explicit,
        category=Category(programinfo.category),
        authors=[globalsettings.owner],
        language=programinfo.language,
        owner=globalsettings.owner,
        feed_url=feed_url(programid),
        new_feed_url=feed_url(programid),
        image=programinfo.image_url,
    )

    for episode in podcasts:
        # Get pubdate from createdate or broadcastdate
        pubdate = digas2pubdate(episode.createdate, episode.broadcastdate)
        # Add the episode to the list
        p.episodes.append(
            Episode(
                title=episode.title,
                media=Media(mp3url(episode.filename), episode.filesize),
                link=mp3url(episode.filename),  # multifeedreader uses this.
                id=guid(episode.filename),
                summary=episode.remark,
                publication_date=pubdate))

    # send it as unicode
    rss = u'%s' % p
    return HttpResponse(rss, content_type='application/xml')
Пример #22
0
    def test_idSetToFalseSoEnclosureNotUsed(self):
        episode = Episode()
        episode.title = "My first episode"
        episode.media = Media("http://example.com/podcast/episode1.mp3",
                              34328731, "audio/mpeg")
        episode.id = False

        item = episode.rss_entry()
        assert item.find("guid") is None
Пример #23
0
    def setUp(self):

        self.itunes_ns = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
        self.dublin_ns = 'http://purl.org/dc/elements/1.1/'

        fg = Podcast()
        self.title = 'Some Testfeed'
        self.link = 'http://lernfunk.de'
        self.description = 'A cool tent'
        self.explicit = False

        fg.name = self.title
        fg.website = self.link
        fg.description = self.description
        fg.explicit = self.explicit

        fe = fg.add_episode()
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The First Episode'
        self.fe = fe

        #Use also the list directly
        fe = Episode()
        fg.episodes.append(fe)
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The Second Episode'

        fe = fg.add_episode()
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The Third Episode'

        self.fg = fg

        warnings.simplefilter("always")
        def noop(*args, **kwargs):
            pass
        warnings.showwarning = noop
Пример #24
0
def main(event, context):
    dynamodb = boto3.resource('dynamodb', region_name='sa-east-1')

    table = dynamodb.Table('semservidor-dev')

    podcasts = table.scan()

    author = Person("Evandro Pires da Silva", "*****@*****.**")
    p = Podcast(
        name="Sem Servidor",
        description=
        "Podcast dedicado a arquitetura serverless, com conteúdo de qualidade em português.",
        website="https://semservidor.com.br",
        explicit=False,
        copyright="2020 Evandro Pires da Silva",
        language="pr-BR",
        authors=[author],
        feed_url=
        "https://3tz8r90j0d.execute-api.sa-east-1.amazonaws.com/dev/podcasts/rss",
        category=Category("Music", "Music History"),
        owner=author,
        image="http://d30gvsirhz3ono.cloudfront.net/logo_semservidor_teste.jpg",
        web_master=Person(None, "*****@*****.**"))

    items = podcasts['Items']
    for item in items:
        base_url = "http://d30gvsirhz3ono.cloudfront.net/"
        file_path = base_url + item['info']['arquivo']['nome']
        p.episodes += [
            Episode(title=item['info']['episodio'],
                    media=Media(file_path,
                                int(item['info']['arquivo']['tamanho'])),
                    summary=item['info']['descricao'],
                    position=int(item['id']))
        ]

    p.apply_episode_order()
    rss = p.rss_str()

    response = {
        "statusCode": 200,
        "headers": {
            "content-type": "application/xml"
        },
        "body": rss
    }

    return response
Пример #25
0
def genero_feed(puntateList):
    if puntateList:
        # Creo un nuovo podcast
        p = Podcast()

        p.name = "Pascal Rai Radio 2"
        p.description = "Pascal un programma di Matteo Caccia in onda su Radio2 che racconta storie di vita. Episodi grandi o piccoli, stravolgenti o minuti, momenti che hanno modificato per sempre la nostra vita o che, anche se di poco, l'hanno indirizzata. Storie che sono il termometro della temperatura di ognuno di noi e che in parte raccontano chi siamo. "
        p.website = "http://www.raiplayradio.it/programmi/pascal/"
        p.explicit = True
        p.image = "https://rss.draghetti.it/pascal_image.jpg"
        p.feed_url = "https://rss.draghetti.it/pascal.xml"
        p.copyright = "Rai Radio 2"
        p.language = "it-IT"

        for puntata in puntateList:
            episode = Episode()

            episode.title = puntata[0].encode("ascii", "ignore")
            episode.link = puntata[1]

            # La dimensione del file e approssimativa
            episode.media = Media(puntata[3], puntata[4])

            if puntata[2]:
                episode.publication_date = datetime.datetime(
                    int(puntata[2].split("/")[2]),
                    int(puntata[2].split("/")[1]),
                    int(puntata[2].split("/")[0]),
                    20,
                    00,
                    tzinfo=pytz.utc)
            else:
                episode.publication_date = pytz.utc.localize(
                    datetime.datetime.utcnow())

            p.episodes.append(episode)

        # Print to stdout, just as an example
        p.rss_file(rssfile, minimize=False)
Пример #26
0
    def setUp(self):

        self.itunes_ns = 'http://www.itunes.com/dtds/podcast-1.0.dtd'
        self.dublin_ns = 'http://purl.org/dc/elements/1.1/'

        fg = Podcast()
        self.title = 'Some Testfeed'
        self.link = 'http://lernfunk.de'
        self.description = 'A cool tent'
        self.explicit = False

        fg.name = self.title
        fg.website = self.link
        fg.description = self.description
        fg.explicit = self.explicit

        fe = fg.add_episode()
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The First Episode'
        self.fe = fe

        #Use also the list directly
        fe = Episode()
        fg.episodes.append(fe)
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The Second Episode'

        fe = fg.add_episode()
        fe.id = 'http://lernfunk.de/media/654321/1'
        fe.title = 'The Third Episode'

        self.fg = fg

        warnings.simplefilter("always")

        def noop(*args, **kwargs):
            pass

        warnings.showwarning = noop
Пример #27
0
p = Podcast(
    name="Short (Morning) Dhamma Talks by Thanissaro Bhikkhu",
    description=
    """These short Dhamma talks by Thanissaro Bhikkhu were given at Metta Forest Monastery most mornings in both English and Thai. The English portion has been excerpted and offered here for streaming and downloading. The talks last about 3 to 5 minutes.
   Podcast feed generated by [email protected].""",
    website="https://www.dhammatalks.org/mp3_short_index.html",
    explicit=False,
)

#soup = bs(urlopen(MORNING_TALKS_URL), "html.parser")
d = pq(url=MORNING_TALKS_URL)

for episode_tag in d('a.audio'):

    inner_span = episode_tag.find("span")
    #embed()
    if inner_span is not None:
        # todo: warning
        inner_span.drop_tree()
    name = urllib.parse.unquote(episode_tag.text_content().strip())
    url = episode_tag.attrib.get("href")
    if url and name:
        url = urllib.parse.urljoin(BASE_URL, url)
        p.episodes += [Episode(title=name, media=Media(url))]
    else:
        #todo: warning
        pass

rss = p.rss_str()
print(rss)
Пример #28
0
talks = soup.find_all('div', class_='sqs-audio-embed')

p = Podcast(
    name="ASW Talks",
    description="Talks from ASW.",
    website=URL,
    explicit=False,
)
items = []

for talk in talks:
    dateSpeaker = talk['data-author'].split(" - ")
    date = processDate(dateSpeaker[0])
    speaker = "None" if len(dateSpeaker) < 2 else dateSpeaker[1]
    if (talk['data-url'] == ""):
        continue
    else:
        items.append(
            Episode(title=talk['data-title'],
                    media=Media(url=talk['data-url']),
                    summary=f'A talk from ASW by {speaker} on {date}'
                    # author = speaker,
                    # pubDate = date
                    ))

# Add some episodes
p.episodes = items
# Generate the RSS feed
rss = p.rss_str()

print(rss)
Пример #29
0
    def test_mandatoryAttributes(self):
        ep = Episode()
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.title = "A title"
        ep.rss_entry()

        ep.title = ""
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.title = None
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.summary = "A summary"
        ep.rss_entry()

        ep.summary = ""
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.summary = None
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)
Пример #30
0
def create_rss(type, download):
    """Create an example podcast and print it or save it to a file."""
    
    # Create the Podcast & initialize the feed
    default_channel = Channel.defaultChannel()
    
    p = Podcast()
    p.name          = default_channel.name
    p.description   = default_channel.description
    p.website       = default_channel.website
    p.explicit      = default_channel.explicit
    p.image         = default_channel.image

    p.copyright     = default_channel.copyright
    p.language      = default_channel.language
    p.feed_url      = default_channel.feed_url
    p.category      = Category(default_channel.category)
    # p.category = Category('Technology', 'Podcasting')
    # p.xslt      = "https://example.com/feed/stylesheet.xsl"  # URL of XSLT stylesheet

    p.authors   = [Person(default_channel.authors, default_channel.authors_email)]
    p.owner     = Person(default_channel.owner, default_channel.owner_email)

    # Other Attributes
    p.generator = " "
    
    # Others for iTunes
    # p.complete = False
    # p.new_feed_url = 'http://example.com/new-feed.rss'

    # e1 = p.add_episode()
    # e1.id = 'http://lernfunk.de/_MEDIAID_123#1'
    # e1.title = 'First Element'
    # e1.summary = htmlencode('''Lorem ipsum dolor sit amet, consectetur adipiscing elit. Tamen
    #         aberramus a proposito, et, ne longius, prorsus, inquam, Piso, si ista
    #         mala sunt, placet. Aut etiam, ut vestitum, sic sententiam habeas aliam
    #         domesticam, aliam forensem, ut in fronte ostentatio sit, intus veritas
    #         occultetur? Cum id fugiunt, re eadem defendunt, quae Peripatetici,
    #         verba <3.''')
    # e1.link = 'http://example.com'
    # e1.authors = [Person('Lars Kiesow', '*****@*****.**')]
    # e1.publication_date = datetime.datetime(2014, 5, 17, 13, 37, 10, tzinfo=pytz.utc)
    # # e1.media = Media("http://example.com/episodes/loremipsum.mp3", 454599964,
    # #                  duration=
    # #                  datetime.timedelta(hours=1, minutes=32, seconds=19))
    # e1.media = Media("http://example.com/episodes/loremipsum.mp3", 454599964)

    # Add some episodes
    p.episodes += [
       Episode(title = download.title, 
            subtitle = download.subtitle,
            # id=str(uuid.uuid4()),
            position =2,
            media = Media(download.media_url, size=download.media_size, duration=timedelta(seconds=download.media_duration)),
            image = download.image_url,
            publication_date = datetime(year=2021, month=1, day=8, hour=10, minute=0, tzinfo=pytz.utc),
            summary = download.summary)
    ,
       Episode(title="Episode 2 - The Crazy Ones",
            subtitle="this is a cool episode, this is for th crazy ones",
            position=1,
            image="https://github.com/oliverbarreto/PersonalPodcast/raw/main/site-logo-1400x1400.png",
            media=Media("https://github.com/oliverbarreto/PersonalPodcast/raw/main/downloaded_with_pytube_Apple%20Steve%20Jobs%20Heres%20To%20The%20Crazy%20Ones.mp4", type="audio/mpeg", size=989, duration=timedelta(hours=0, minutes=1, seconds=1)),
            publication_date = datetime(year=2021, month=1, day=6, hour=10, minute=0, tzinfo=pytz.utc),
            summary=htmlencode("wow wow wow summary"))
    ,
        Episode(title="Episode 3 - The Super Crazy",
            subtitle="crazy ones revisited",
            position=0,
            image="https://github.com/oliverbarreto/PersonalPodcast/raw/main/site-logo-1400x1400.png",
            media=Media("https://drive.google.com/file/d/1X5Mwa8V0Su1IDqhcQL7LdzEY0VaMC1Nn", type="audio/mpeg", size=989, duration=timedelta(hours=0, minutes=1, seconds=1)),
            publication_date = datetime(year=2021, month=1, day=10, hour=10, minute=0, tzinfo=pytz.utc),
            summary=download.summary)
    ]

    # Should we just print out, or write to file?
    if type == 'print':
        # Print
        print_enc(p.rss_str())
    elif type== 'feed.xml':
        # Write to file
        p.rss_file(type, minimize=False)
        print("\n")
        print("feed.xml created !!!")
Пример #31
0
p = Podcast(
    name="Chapo Cheaters Club",
    description="Just taking"
    "what isn't mine",
    website=host_address,
    explicit=False,
)

p.image = host_address + "logo.jpg"

for pod in find_pods():
    audio = MP3(os.path.join(base_dir, pod_dir, pod), ID3=EasyID3)
    if audio:
        title = str(*audio["title"])
    else:
        title = pod[:~3]
    size = os.path.getsize(os.path.join(base_dir, pod_dir, pod))
    duration = timedelta(seconds=audio.info.length)
    print(f'{pod}, {title}, {size}, {duration}')
    p.episodes += [
        Episode(title=title,
                media=Media(f"{host_address}{pod}",
                            size=size,
                            duration=duration),
                summary="summary goes here")
    ]

rss = p.rss_str()
p.rss_file(os.path.join(base_dir, pod_dir, 'rss.xml'))
Пример #32
0
        # Save the meeting details.
        with open(f"{output_prefix}.yaml", "w") as fp:
            fp.write(yaml.dump(meeting))

    # Update podcast.
    podcast = Podcast(
        name="Zoomerang",
        description="Telecons you missed while you were sleeping.",
        website=config["zoomerang_remote_addr"],
        explicit=False)

    meeting_paths = glob(f"{recordings_dir_path}*.yaml")
    for meeting_path in meeting_paths:
        with open(meeting_path, "r") as fp:
            meeting = yaml.load(fp)

        podcast.add_episode(
            Episode(title=meeting["summary"],
                    media=Media(meeting["url"],
                                size=meeting["estimated_file_size"],
                                type="audio/mpeg",
                                duration=datetime.timedelta(
                                    seconds=meeting["duration"])),
                    publication_date=dateutil.parser.parse(
                        meeting["created_datetime"])))

    with open(config["zoomerang_podcast_path"], "w") as fp:
        fp.write(f"{podcast}")

    print("Updated podcast.")
Пример #33
0
from podgen import Podcast, Episode, Media
# Create the Podcast
p = Podcast(
    name="Animals Alphabetically",
    description="Every Tuesday, biologist John Doe and wildlife "
    "photographer Foo Bar introduce you to a new animal.",
    website="http://example.org/animals-alphabetically",
    explicit=False,
)
# Add some episodes
p.episodes += [
    Episode(
        title="Aardvark",
        media=Media("http://example.org/files/aardvark.mp3", 11932295),
        summary="With an English name adapted directly from Afrikaans "
        '-- literally meaning "earth pig" -- this fascinating '
        "animal has both circular teeth and a knack for "
        "digging.",
    ),
    Episode(
        title="Alpaca",
        media=Media("http://example.org/files/alpaca.mp3", 15363464),
        summary="Thousands of years ago, alpacas were already "
        "domesticated and bred to produce the best fibers. "
        "Case in point: we have found clothing made from "
        "alpaca fiber that is 2000 years old. How is this "
        "possible, and what makes it different from llamas?",
    ),
]
# Generate the RSS feed
rss = p.rss_str()
Пример #34
0
print('>>> wrote fresh sessions.json file')

# write the new rss file
p = Podcast()

p.name = "The Objectivism Seminar"
p.category = Category("Society &amp; Culture", "Philosophy")
p.language = "en-US"
p.explicit = True
p.description = (
    "A weekly online conference call to systematically study " +
    "the philosophy of Objectivism via the works of prominent Rand scholars.")
p.website = "https://www.ObjectivismSeminar.com"
p.image = "https://www.ObjectivismSeminar.com/assets/images/atlas-square.jpg"
p.feed_url = "https://www.ObjectivismSeminar.com/archives/rss"
p.authors = [Person("Greg Perkins, Host", "*****@*****.**")]
p.owner = Person("Greg Perkins", "*****@*****.**")

p.episodes += [
    Episode(title=x['title'],
            media=Media(x['link'], type="audio/mpeg", size=x['length']),
            id=x['GUID'],
            publication_date=x['pubDate'],
            summary=x['description']) for x in updated_session_items
]

p.rss_file(rss_filename)

print('>>> wrote fresh rss.xml file')
Пример #35
0
episodes = []

for url in urls_to_follow:
    content = requests.get(url).content
    soup = BeautifulSoup(content, features="lxml")
    res = re.search(b'file : "(.+?)",\\n', content)
    title = soup.select("b.vod-title")[0].text
    date = soup.select(".vod-data p span.episode-date")[0].text
    media_url = res.groups()[0].decode()
    head = requests.head(url)
    if '\n' in title:
       title = title.split('\n')[-1]
    episodes.append(
       Episode(
          title=title.title(),
          media=Media(media_url, head.headers["Content-Length"]),
          summary=soup.title.text,
          publication_date=arrow.get(date, "DD MMM. YYYY", locale="pt").datetime
       )
   )


# Add some episodes
p.episodes = episodes
# Generate the RSS feed
rss = p.rss_str()

filename = "alta-tensao.xml"

with open(filename, "wb") as f:
   f.write(rss.encode())
Пример #36
0
                'filename': file_local_path,
                'name': video.title
            })
        except HTTPError as err:
            print('Can not parse this video bacause of HTTPError.')

# Create Podcast object and fill it with episodes
podcast_object = Podcast(
    name=CONFIG['podcast_name'],
    description=CONFIG['podcast_description'],
    website=CONFIG['podcast_website'],
    explicit=False,
    image=CONFIG['podcast_image'],
    language=CONFIG['podcast_language'],
    authors=[Person(CONFIG['podcast_author'], CONFIG['podcast_author_email'])],
    owner=Person(CONFIG['podcast_owner'], CONFIG['podcast_owner_email']),
    category=Category(CONFIG['podcast_category'],
                      CONFIG['podcast_subcategory']))

for item in db:
    web_media_path = "%s/podcast_%s.mp4" % (CONFIG['podcast_media_server'],
                                            item['link'][9:])
    podcast_object.add_episode(
        Episode(title=item['name'],
                media=Media(web_media_path,
                            os.stat(item['filename']).st_size,
                            type="audio/mpeg")))

# Generating RSS
podcast_object.rss_file(('%s/rss.xml' % CONFIG['data_path']), minimize=True)
Пример #37
0
    def test_mandatoryAttributes(self):
        ep = Episode()
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.title = "A title"
        ep.rss_entry()

        ep.title = ""
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.title = None
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.summary = "A summary"
        ep.rss_entry()

        ep.summary = ""
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)

        ep.summary = None
        self.assertRaises((RuntimeError, ValueError), ep.rss_entry)
Пример #38
0
def generate(name, description, website, explicit, image, author_name,
             author_email, feed_path, copyright, language, category, blog,
             blog_path, verbose, folder):
    """Generate a podcast from mp3 files located in the provided FOLDER"""
    if verbose:
        logging.basicConfig(level=logging.DEBUG)
    else:
        logging.basicConfig(level=logging.INFO)

    attrs = locals()
    logging.debug('Processing input: %s' % (attrs))
    del attrs['folder']
    del attrs['author_name']
    del attrs['author_email']
    del attrs['verbose']
    del attrs['feed_path']
    del attrs['blog']
    del attrs['blog_path']

    attrs['authors'] = [Person(author_name, author_email)]
    attrs['owner'] = attrs['authors'][0]

    attrs['category'] = Category(category)

    feed_name = name.lower().replace(' ', '_') + '.rss'
    feed_base = '%s/%s' % (website, feed_path)
    feed_url = '%s/%s' % (feed_base, feed_name)
    attrs['feed_url'] = feed_url

    logging.info('Creating podcast %s, feed %s' % (name, feed_url))
    p = Podcast(**attrs)

    for fpath in sorted(glob.glob('%s*.mp3' % (folder))):
        logging.info('Adding episode %s' % (fpath))
        fname = os.path.basename(fpath)
        size = os.path.getsize(fpath)
        logging.debug('Filename: %s, size %i' % (fname, size))
        try:
            tag = ID3(fpath)
        except ID3NoHeaderError:
            logging.error('%s is not a valid mp3 file, ignoring it' % (fpath))
            continue
        logging.debug('Read tag: %s' % (tag))
        e = Episode()
        if 'TPE1' in tag:
            e.authors = [Person(tag['TPE1'][0])]
        else:
            e.authors = attrs['authors']
        e.title = tag['TIT2'][0]
        e.subtitle = e.title
        if 'COMM::eng' in tag:
            e.summary = tag['COMM::eng'][0]
        else:
            e.summary = description
        episode_url = '%s/%s' % (feed_base, fname)
        logging.debug('Episode url: %s' % (episode_url))
        e.media = Media(episode_url, size, type='audio/mpeg')
        e.media.populate_duration_from(fpath)
        pubdate = datetime.strptime(tag['TDRC'][0].text[:10], '%Y-%m-%d')
        pubdate = pubdate.replace(tzinfo=pytz.utc)
        e.publication_date = pubdate
        if blog:
            blog_post = ''
            short_name = re.search('[a-z]*_-_([a-z_]*[#0-9]*)', fname)
            if short_name:
                blog_post = short_name.group(1).replace('_', '-').\
                    replace('#', '') + '.html'
                e.link = '%s/%s/%s' % (website, blog_path, blog_post)
        p.episodes.append(e)

    feed_local_path = '%s%s' % (folder, feed_name)
    logging.info('Generating feed in %s' % (feed_local_path))
    p.rss_file(feed_local_path, minimize=False)
Пример #39
0
p = Podcast(
    name="365 days of plops",
    description="Every shit I take "
    "you get to hear it",
    website="http://example.org/animals-alphabetically",
    explicit=False,
)

p.image = "https://github.com/ssk8/365days_of_plops/raw/main/pooping.jpg"

p.episodes += [
    Episode(
        title="just a turd",
        media=Media(
            "https://github.com/ssk8/365days_of_plops/raw/main/poop01.mp3",
            11932295),
        summary="With an English name adapted directly from Afrikaans "
        '-- literally meaning "earth pig" -- this fascinating '
        "animal has both circular teeth and a knack for "
        "digging.",
    ),
    Episode(
        title="ya, das ist die heiße scheiße",
        media=Media(
            "https://github.com/ssk8/365days_of_plops/raw/main/poop02.mp3",
            15363464),
        summary="Colon evacuation "
        "hurt my anus ",
    ),
    Episode(
        title="Spicy Shit",
        media=Media(