nr/processpodcastsubscriptions

订阅播客RSS源并将其保存为新页面

1.0.4 2024-01-30 08:27 UTC

This package is auto-updated.

Last update: 2024-09-30 01:38:01 UTC


README

功能

订阅播客RSS源并将其数据保存为任何您想要的内容。该模块使用Lukas White的出色PHP库podcast-feed-parser,使得处理播客数据变得轻松。感谢!

该模块附带一个示例模块 ProcessPodcastSubscriptionsEpisodes,以展示如何为每集创建新页面。

功能

  • 订阅/取消订阅播客XML源
  • 使用LazyCron定期抓取源
  • 简单的可钩子动作
  • 管理用的ProcessModule
  • 可选模块 ProcessPodcastSubscriptionsEpisodes

安装

  1. 将此模块的文件复制到 /site/modules/ProcessPodcastSubscriptions/
  2. 在 /site/modules/ProcessPodcastSubscriptions/ 目录中执行以下命令。
    composer install
  3. 如果没有自动执行,则创建一个带有进程 ProcessPodcastSubscriptions 的新管理页面
  4. 安装可选模块 ProcessPodcastSubscriptionsEpisodes 或构建自己的处理器
  5. 订阅播客源...

通过composer安装

  1. 在您的网站根目录中执行以下命令。
    composer require nr/processpodcastsubscriptions

配置订阅

模块 > 配置 > ProcessPodcastSubscriptions

Lazycron

设置LazyCron计划。缓存过期时间可在字段设置中配置。

Lazycron

剧集元数据

您可以为播客添加订阅链接。配置提供者然后将链接附加到播客。

Episode Parent

配置剧集

模块 > 配置 > ProcessPodcastSubscriptionsEpisodes

剧集父级

为新剧集页面设置父页面。

Episode Parent

播客类和剧集类

《播客》对象有很多实用的方法来处理返回的数据。

class Podcast implements HasArtwork {
   
   public array getEpisodes()
   public string getLanguage()
   public string getAuthor()
   public string getTitle()
   public string getSubtitle()
   public string getDescription()
   public DateTime getLastBuildDate()
   
   public string getType()
   public bool isEpisodic()
   public bool isSerial()
   
   public string getUpdatePeriod()
   public Artwork getArtwork()
   public string getExplicit()
   public array getCategories()
   
   /* ... and much more ... */
}
class Episode {

    public string getGuid()
    public int getEpisodeNumber()
    public Media getMedia()
    public DateTime getPublishedDate()
    public string getTitle()
    public string getDescription()
    public Artwork getArtwork()
    public string getLink()
    public string getExplicit()
    
    /* ... and much more ... */
}

钩子

// init.php or ready.php
$wire->addHookBefore('ProcessPodcastSubscriptions::processPodcast', function (HookEvent $event) {

    /** @var \ProcessWire\WireData $feed */
    $feed = $event->arguments(0);

    /** @var \Lukaswhite\PodcastFeedParser\Podcast $podcast */
    $podcast = $event->arguments(1);
    
    // process
    foreach($podcast->getEpisodes() as $episode) {
        /* create or update episode pages... */
    }

});

示例渲染

ProcessPodcastSubscriptions/templates/podcasts-example.php 文件夹中,您可以找到播客和剧集列表的示例渲染。享受其中。

Episode Parent

待办事项

  • 尊重源中的lastBuildDate以执行更新操作。
  • 处理订阅时的长时间运行脚本。