generating feed

This commit is contained in:
Max Nuding 2022-01-11 17:04:32 +01:00
parent 9b6639ad3c
commit 9806399a99
Signed by: phlaym
GPG Key ID: A06651BAB6777237
5 changed files with 459 additions and 3 deletions

View File

@ -1,5 +1,9 @@
{
"username": "",
"password": "",
"driver_path": null
"driver_path": null,
"last_generated_ts": 0,
"feed_cache_time_seconds": 3600,
"output_file": "feed.rss",
"feed_url": ""
}

19
main.py
View File

@ -1,16 +1,31 @@
#!/usr/bin/env python3
import json
import os
import time
import nebula_rss
if __name__ == '__main__':
config = {}
with open('config.json') as config_file:
config_file_path = 'config.json'
with open(config_file_path) as config_file:
config = json.load(config_file)
loader = nebula_rss.nebula_loader.NebulaLoader(
username=config['username'],
password=config['password'],
driver_path=config.get('driver_path', None)
)
loader.load()
current_ts = time.time()
last_generation_time = config.get('last_generated_ts', 0)
feed_cache_time_seconds = config.get('feed_cache_time_seconds', 3600)
time_since_last_generation = current_ts - last_generation_time
if time_since_last_generation <= feed_cache_time_seconds and os.path.isfile(config['output_file']):
exit(0)
feed = nebula_rss.NebulaFeed(nebula_loader=loader, feed_url=config['feed_url'])
# generates bytes, not string for whatever reason
with open(config['output_file'], 'wb') as output_file:
output_file.write(feed.generate())
last_generation_time = config['last_generated_ts'] = current_ts
with open(config_file_path, 'w') as config_file:
json.dump(config, config_file)

400
nebula.rss Normal file
View File

@ -0,0 +1,400 @@
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
<id>https://phlaym.net/feeds/nebula.rss</id>
<title>Nebula subscriptions</title>
<updated>2022-01-11T15:58:08.097960+00:00</updated>
<link href="https://phlaym.net/feeds/nebula.rss" rel="self"/>
<generator uri="https://lkiesow.github.io/python-feedgen" version="0.9.0">python-feedgen</generator>
<logo>https://nebula.app/apple-touch-icon.png</logo>
<subtitle>Your subscribed videos</subtitle>
<entry>
<id>https://nebula.app/videos/sarah-z-what-went-wrong-with-dear-evan-hansen</id>
<title>What Went Wrong With Dear Evan Hansen</title>
<updated>2022-01-11T15:58:08.098619+00:00</updated>
<author>
<name>SarahZ</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/sarah-z-what-went-wrong-with-dear-evan-hansen" rel="alternate"/>
<link href="https://nebula.app/videos/sarah-z-what-went-wrong-with-dear-evan-hansen" rel="enclosure"/>
<summary>New video by SarahZ: What Went Wrong With Dear Evan Hansen</summary>
<published>2021-12-05T07:23:08+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/half-as-interesting-how-one-terrible-trader-bankrupted-barings-bank</id>
<title>How One Terrible Trader Bankrupted Barings Bank</title>
<updated>2022-01-11T15:58:08.098602+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/half-as-interesting-how-one-terrible-trader-bankrupted-barings-bank" rel="alternate"/>
<link href="https://nebula.app/videos/half-as-interesting-how-one-terrible-trader-bankrupted-barings-bank" rel="enclosure"/>
<summary>New video by Half as Interesting: How One Terrible Trader Bankrupted Barings Bank</summary>
<published>2021-12-07T18:15:58+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/legaleagle-real-lawyer-reacts-to-its-always-sunny-hero-or-hate-crime</id>
<title>Real Lawyer Reacts to It's Always Sunny (Hero or Hate Crime)</title>
<updated>2022-01-11T15:58:08.098585+00:00</updated>
<author>
<name>Legal Eagle</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/legaleagle-real-lawyer-reacts-to-its-always-sunny-hero-or-hate-crime" rel="alternate"/>
<link href="https://nebula.app/videos/legaleagle-real-lawyer-reacts-to-its-always-sunny-hero-or-hate-crime" rel="enclosure"/>
<summary>New video by Legal Eagle: Real Lawyer Reacts to It's Always Sunny (Hero or Hate Crime)</summary>
<published>2021-12-08T21:47:41+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/half-as-interesting-why-planes-fly-over-the-north-pole-but-not-the-south-pole</id>
<title>Why Planes Fly Over The North Pole But Not The South Pole</title>
<updated>2022-01-11T15:58:08.098568+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/half-as-interesting-why-planes-fly-over-the-north-pole-but-not-the-south-pole" rel="alternate"/>
<link href="https://nebula.app/videos/half-as-interesting-why-planes-fly-over-the-north-pole-but-not-the-south-pole" rel="enclosure"/>
<summary>New video by Half as Interesting: Why Planes Fly Over The North Pole But Not The South Pole</summary>
<published>2021-12-09T15:39:25+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/legaleagle-are-the-crumbley-parents-responsible-for-the-shooting-too</id>
<title>Are The Crumbley Parents Responsible for the Shooting Too?</title>
<updated>2022-01-11T15:58:08.098500+00:00</updated>
<author>
<name>Legal Eagle</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/legaleagle-are-the-crumbley-parents-responsible-for-the-shooting-too" rel="alternate"/>
<link href="https://nebula.app/videos/legaleagle-are-the-crumbley-parents-responsible-for-the-shooting-too" rel="enclosure"/>
<summary>New video by Legal Eagle: Are The Crumbley Parents Responsible for the Shooting Too?</summary>
<published>2021-12-11T04:38:06+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/people-make-games-roblox-pressured-us-to-delete-our-video-so-we-dug-deeper</id>
<title>Roblox Pressured Us to Delete Our Video. So We Dug Deeper.</title>
<updated>2022-01-11T15:58:08.098482+00:00</updated>
<author>
<name>People Make Games</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/people-make-games-roblox-pressured-us-to-delete-our-video-so-we-dug-deeper" rel="alternate"/>
<link href="https://nebula.app/videos/people-make-games-roblox-pressured-us-to-delete-our-video-so-we-dug-deeper" rel="enclosure"/>
<summary>New video by People Make Games: Roblox Pressured Us to Delete Our Video. So We Dug Deeper.</summary>
<published>2021-12-13T14:38:31+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/wendover-productions-how-airlines-quietly-became-banks</id>
<title>How Airlines Quietly Became Banks</title>
<updated>2022-01-11T15:58:08.098461+00:00</updated>
<author>
<name>Wendover</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/wendover-productions-how-airlines-quietly-became-banks" rel="alternate"/>
<link href="https://nebula.app/videos/wendover-productions-how-airlines-quietly-became-banks" rel="enclosure"/>
<summary>New video by Wendover: How Airlines Quietly Became Banks</summary>
<published>2021-12-14T15:35:32+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/uno-dos-of-trace-do-dads-even-matter</id>
<title>Do Dads Even Matter?</title>
<updated>2022-01-11T15:58:08.098444+00:00</updated>
<author>
<name>Uno Dos of Trace</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/uno-dos-of-trace-do-dads-even-matter" rel="alternate"/>
<link href="https://nebula.app/videos/uno-dos-of-trace-do-dads-even-matter" rel="enclosure"/>
<summary>New video by Uno Dos of Trace: Do Dads Even Matter?</summary>
<published>2021-12-15T22:31:16+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/half-as-interesting-why-sweden-is-moving-its-northernmost-town-2-miles-east</id>
<title>Why Sweden Is Moving Its Northernmost Town 2 Miles East</title>
<updated>2022-01-11T15:58:08.098427+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/half-as-interesting-why-sweden-is-moving-its-northernmost-town-2-miles-east" rel="alternate"/>
<link href="https://nebula.app/videos/half-as-interesting-why-sweden-is-moving-its-northernmost-town-2-miles-east" rel="enclosure"/>
<summary>New video by Half as Interesting: Why Sweden Is Moving Its Northernmost Town 2 Miles East</summary>
<published>2021-12-16T17:11:45+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/up-and-atom-this-paradox-proves-einsteins-special-relativity</id>
<title>This Paradox Proves Einstein's Special Relativity</title>
<updated>2022-01-11T15:58:08.098410+00:00</updated>
<author>
<name>Up and Atom</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/up-and-atom-this-paradox-proves-einsteins-special-relativity" rel="alternate"/>
<link href="https://nebula.app/videos/up-and-atom-this-paradox-proves-einsteins-special-relativity" rel="enclosure"/>
<summary>New video by Up and Atom: This Paradox Proves Einstein's Special Relativity</summary>
<published>2021-12-17T05:01:58+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/mia-mulder-were-elagabalus-and-queen-kristina-transgender-mia-mulder</id>
<title>Were Elagabalus And Queen Kristina Transgender? | Mia Mulder</title>
<updated>2022-01-11T15:58:08.098393+00:00</updated>
<author>
<name>Mia Mulder</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/mia-mulder-were-elagabalus-and-queen-kristina-transgender-mia-mulder" rel="alternate"/>
<link href="https://nebula.app/videos/mia-mulder-were-elagabalus-and-queen-kristina-transgender-mia-mulder" rel="enclosure"/>
<summary>New video by Mia Mulder: Were Elagabalus And Queen Kristina Transgender? | Mia Mulder</summary>
<published>2021-12-17T21:42:56+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/real-engineering-the-insane-engineering-of-the-james-webb-telescope</id>
<title>The Insane Engineering of the James Webb Telescope</title>
<updated>2022-01-11T15:58:08.098376+00:00</updated>
<author>
<name>Real Engineering</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/real-engineering-the-insane-engineering-of-the-james-webb-telescope" rel="alternate"/>
<link href="https://nebula.app/videos/real-engineering-the-insane-engineering-of-the-james-webb-telescope" rel="enclosure"/>
<summary>New video by Real Engineering: The Insane Engineering of the James Webb Telescope</summary>
<published>2021-12-18T18:04:38+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/real-science-the-insane-biology-of-the-orca</id>
<title>The Insane Biology of: The Orca</title>
<updated>2022-01-11T15:58:08.098357+00:00</updated>
<author>
<name>Real Science</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/real-science-the-insane-biology-of-the-orca" rel="alternate"/>
<link href="https://nebula.app/videos/real-science-the-insane-biology-of-the-orca" rel="enclosure"/>
<summary>New video by Real Science: The Insane Biology of: The Orca</summary>
<published>2021-12-18T23:34:11+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/techaltar-how-911-google-changed-cinema</id>
<title>How 9/11 &amp; Google Changed Cinema</title>
<updated>2022-01-11T15:58:08.098340+00:00</updated>
<author>
<name>TechAltar</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/techaltar-how-911-google-changed-cinema" rel="alternate"/>
<link href="https://nebula.app/videos/techaltar-how-911-google-changed-cinema" rel="enclosure"/>
<summary>New video by TechAltar: How 9/11 &amp; Google Changed Cinema</summary>
<published>2021-12-20T15:00:00+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/legaleagle-the-most-bizarre-legal-defenses-that-worked</id>
<title>The Most Bizarre Legal Defenses (That Worked!)</title>
<updated>2022-01-11T15:58:08.098323+00:00</updated>
<author>
<name>Legal Eagle</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/legaleagle-the-most-bizarre-legal-defenses-that-worked" rel="alternate"/>
<link href="https://nebula.app/videos/legaleagle-the-most-bizarre-legal-defenses-that-worked" rel="enclosure"/>
<summary>New video by Legal Eagle: The Most Bizarre Legal Defenses (That Worked!)</summary>
<published>2021-12-20T15:22:39+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/sarahz-why-the-mean-girls-musical-doesnt-work</id>
<title>Why The Mean Girls Musical Doesn't Work</title>
<updated>2022-01-11T15:58:08.098303+00:00</updated>
<author>
<name>SarahZ</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/sarahz-why-the-mean-girls-musical-doesnt-work" rel="alternate"/>
<link href="https://nebula.app/videos/sarahz-why-the-mean-girls-musical-doesnt-work" rel="enclosure"/>
<summary>New video by SarahZ: Why The Mean Girls Musical Doesn't Work</summary>
<published>2021-12-22T10:46:44+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/hai-why-almost-every-town-in-america-has-a-thai-restaurant</id>
<title>Why Almost Every Town In America Has a Thai Restaurant</title>
<updated>2022-01-11T15:58:08.098286+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/hai-why-almost-every-town-in-america-has-a-thai-restaurant" rel="alternate"/>
<link href="https://nebula.app/videos/hai-why-almost-every-town-in-america-has-a-thai-restaurant" rel="enclosure"/>
<summary>New video by Half as Interesting: Why Almost Every Town In America Has a Thai Restaurant</summary>
<published>2021-12-22T14:35:12+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/techaltar-the-phone-company-tier-list-2021</id>
<title>The phone company tier list - 2021</title>
<updated>2022-01-11T15:58:08.098268+00:00</updated>
<author>
<name>TechAltar</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/techaltar-the-phone-company-tier-list-2021" rel="alternate"/>
<link href="https://nebula.app/videos/techaltar-the-phone-company-tier-list-2021" rel="enclosure"/>
<summary>New video by TechAltar: The phone company tier list - 2021</summary>
<published>2021-12-23T13:42:02+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/hai-the-real-reason-nyc-is-always-covered-in-scaffolding</id>
<title>The Real Reason NYC Is Always Covered In Scaffolding</title>
<updated>2022-01-11T15:58:08.098248+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/hai-the-real-reason-nyc-is-always-covered-in-scaffolding" rel="alternate"/>
<link href="https://nebula.app/videos/hai-the-real-reason-nyc-is-always-covered-in-scaffolding" rel="enclosure"/>
<summary>New video by Half as Interesting: The Real Reason NYC Is Always Covered In Scaffolding</summary>
<published>2021-12-23T18:24:44+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/legaleagle-why-alex-jones-lost-the-sandy-hook-suits</id>
<title>Why Alex Jones Lost the Sandy Hook Suits</title>
<updated>2022-01-11T15:58:08.098231+00:00</updated>
<author>
<name>Legal Eagle</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/legaleagle-why-alex-jones-lost-the-sandy-hook-suits" rel="alternate"/>
<link href="https://nebula.app/videos/legaleagle-why-alex-jones-lost-the-sandy-hook-suits" rel="enclosure"/>
<summary>New video by Legal Eagle: Why Alex Jones Lost the Sandy Hook Suits</summary>
<published>2021-12-27T20:41:07+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/tracedominguez-are-lgbtq-better-parents</id>
<title>Are LGBTQ+ Better Parents?</title>
<updated>2022-01-11T15:58:08.098214+00:00</updated>
<author>
<name>Uno Dos of Trace</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/tracedominguez-are-lgbtq-better-parents" rel="alternate"/>
<link href="https://nebula.app/videos/tracedominguez-are-lgbtq-better-parents" rel="enclosure"/>
<summary>New video by Uno Dos of Trace: Are LGBTQ+ Better Parents?</summary>
<published>2021-12-28T01:06:45+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-1</id>
<title>The News You Missed in 2021, From Every Country in the World (Part 1)</title>
<updated>2022-01-11T15:58:08.098197+00:00</updated>
<author>
<name>Wendover</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-1" rel="alternate"/>
<link href="https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-1" rel="enclosure"/>
<summary>New video by Wendover: The News You Missed in 2021, From Every Country in the World (Part 1)</summary>
<published>2021-12-28T13:16:23+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-2</id>
<title>The News You Missed in 2021, From Every Country in the World (Part 2)</title>
<updated>2022-01-11T15:58:08.098179+00:00</updated>
<author>
<name>Wendover</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-2" rel="alternate"/>
<link href="https://nebula.app/videos/wendover-the-news-you-missed-in-2021-from-every-country-in-the-world-part-2" rel="enclosure"/>
<summary>New video by Wendover: The News You Missed in 2021, From Every Country in the World (Part 2)</summary>
<published>2021-12-28T13:29:12+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/tracedominguez-how-babies-rewire-your-brain</id>
<title>How Babies Rewire Your Brain</title>
<updated>2022-01-11T15:58:08.098162+00:00</updated>
<author>
<name>Uno Dos of Trace</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/tracedominguez-how-babies-rewire-your-brain" rel="alternate"/>
<link href="https://nebula.app/videos/tracedominguez-how-babies-rewire-your-brain" rel="enclosure"/>
<summary>New video by Uno Dos of Trace: How Babies Rewire Your Brain</summary>
<published>2021-12-29T13:59:00+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/tracedominguez-3-stereotypes-that-hurt-kids-and-how-to-stop-them</id>
<title>3 Stereotypes that Hurt Kids (and How to Stop Them)</title>
<updated>2022-01-11T15:58:08.098145+00:00</updated>
<author>
<name>Uno Dos of Trace</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/tracedominguez-3-stereotypes-that-hurt-kids-and-how-to-stop-them" rel="alternate"/>
<link href="https://nebula.app/videos/tracedominguez-3-stereotypes-that-hurt-kids-and-how-to-stop-them" rel="enclosure"/>
<summary>New video by Uno Dos of Trace: 3 Stereotypes that Hurt Kids (and How to Stop Them)</summary>
<published>2021-12-30T13:59:00+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/hai-who-officially-decides-what-time-it-is</id>
<title>Who Officially Decides What Time It Is?</title>
<updated>2022-01-11T15:58:08.098127+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/hai-who-officially-decides-what-time-it-is" rel="alternate"/>
<link href="https://nebula.app/videos/hai-who-officially-decides-what-time-it-is" rel="enclosure"/>
<summary>New video by Half as Interesting: Who Officially Decides What Time It Is?</summary>
<published>2021-12-31T15:59:55+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/hai-why-dont-artificial-flavors-taste-accurate</id>
<title>Why Dont Artificial Flavors Taste Accurate?</title>
<updated>2022-01-11T15:58:08.098108+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/hai-why-dont-artificial-flavors-taste-accurate" rel="alternate"/>
<link href="https://nebula.app/videos/hai-why-dont-artificial-flavors-taste-accurate" rel="enclosure"/>
<summary>New video by Half as Interesting: Why Dont Artificial Flavors Taste Accurate?</summary>
<published>2022-01-04T16:12:54+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/legaleagle-celebrities-sued-for-posting-photos-of-themselves</id>
<title>Celebrities Sued For Posting Photos of Themselves</title>
<updated>2022-01-11T15:58:08.098089+00:00</updated>
<author>
<name>Legal Eagle</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/legaleagle-celebrities-sued-for-posting-photos-of-themselves" rel="alternate"/>
<link href="https://nebula.app/videos/legaleagle-celebrities-sued-for-posting-photos-of-themselves" rel="enclosure"/>
<summary>New video by Legal Eagle: Celebrities Sued For Posting Photos of Themselves</summary>
<published>2022-01-04T22:12:45+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/hai-the-bug-that-created-free-public-wifi-networks-that-didnt-work</id>
<title>The Bug That Created “Free Public Wifi” Networks That Didnt Work</title>
<updated>2022-01-11T15:58:08.098065+00:00</updated>
<author>
<name>Half as Interesting</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/hai-the-bug-that-created-free-public-wifi-networks-that-didnt-work" rel="alternate"/>
<link href="https://nebula.app/videos/hai-the-bug-that-created-free-public-wifi-networks-that-didnt-work" rel="enclosure"/>
<summary>New video by Half as Interesting: The Bug That Created “Free Public Wifi” Networks That Didnt Work</summary>
<published>2022-01-06T15:39:39+00:00</published>
</entry>
<entry>
<id>https://nebula.app/videos/wendover-electric-vehicles-battery-problem</id>
<title>Electric Vehicles' Battery Problem</title>
<updated>2022-01-11T15:58:08.098012+00:00</updated>
<author>
<name>Wendover</name>
<email>Unknown</email>
</author>
<link href="https://nebula.app/videos/wendover-electric-vehicles-battery-problem" rel="alternate"/>
<link href="https://nebula.app/videos/wendover-electric-vehicles-battery-problem" rel="enclosure"/>
<summary>New video by Wendover: Electric Vehicles' Battery Problem</summary>
<published>2022-01-11T15:03:33+00:00</published>
</entry>
</feed>

View File

@ -2,3 +2,4 @@ __version__ = '0.1.0'
from nebula_rss.nebula_video import NebulaVideo
from nebula_rss.nebula_loader import NebulaLoader
from nebula_rss.nebula_feed import NebulaFeed

36
nebula_rss/nebula_feed.py Normal file
View File

@ -0,0 +1,36 @@
from feedgen.feed import FeedGenerator
from nebula_rss import NebulaLoader
class NebulaFeed:
def __init__(self, nebula_loader: NebulaLoader, feed_url: str):
self.nebula_loader = nebula_loader
self.feed_url = feed_url
def generate(self, format: str = 'atom') -> str:
videos = self.nebula_loader.load()
fg = FeedGenerator()
fg.id(self.feed_url)
fg.title('Nebula subscriptions')
fg.logo('https://nebula.app/apple-touch-icon.png')
fg.subtitle('Your subscribed videos')
fg.link(href=self.feed_url, rel='self')
fg.language('en')
for video in videos:
fe = fg.add_entry()
fe.id(video.url)
fe.title(video.title)
fe.link(href=video.url)
fe.author({'name': video.creator, 'email': 'Unknown'}) # Email is required for RSS format, but is not known
fe.enclosure(url=video.url)
fe.summary(f'New video by {video.creator}: {video.title}')
fe.published(video.release_at)
feed = ''
if format == 'atom':
feed = fg.atom_str(pretty=True)
elif format == 'rss':
feed = fg.rss_str(pretty=True)
else:
raise Exception(f'Unknown format: "{format}". Use "atom" or "rss')
return feed