跳转到主要内容

Spotify Podcast 数据连接器

项目描述

Spotify Connector

Docs

OpenPodcast Banner

这是一个连接到非官方Spotify播客API的简单库。
它可以用来从https://podcasters.spotify.com/home的仪表板导出数据。

支持的数据

  • 剧集列表
  • 开始和流
  • 听众
  • 关注者
  • 性别
  • 年龄
  • 国家
  • 剧集性能

凭证

在您可以使用该库之前,您必须从仪表板提取您的Spotify凭证;它们不是通过您的Spotify设置公开的。

您可以使用我们的网络扩展来做这件事,或者查看代码来了解如何手动操作。

安装

pip install spotifyconnector

作为库使用

from spotifyconnector import SpotifyConnector

# Set up the connector
connector = SpotifyConnector(
    client_id="your_client_id",
    client_secret="your_client_secret",
    redirect_uri="your_redirect_uri",
    refresh_token="your_refresh_token",
)

# Get podcast metadata
connector.metadata()

# Get the list of listeners of a podcast
listeners = connector.listeners()

# Get the aggregated listeners of a podcast (by age, country, gender)
aggregate = connector.aggregate()

# Iterate over all episodes (supports pagination)
for episode in connector.episodes():
    # Do something with episode
    pass

# Get the performance of an episode
performance = connector.performance("episode_id")

# ...

查看__main.py__以获取所有端点。

本地测试

您可以在本地运行脚本以进行测试

make dev

要使用详细日志记录运行脚本

export LOGURU_LEVEL=TRACE
make dev

开发

我们使用Pipenv进行虚拟环境和开发依赖项管理。安装Pipenv后

  1. 开发模式下安装您本地签出的代码及其依赖项,以及所有开发依赖项到一个虚拟环境中
pipenv sync --dev
  1. 创建一个环境文件并填写所需的值
cp .env.example .env
  1. 在虚拟环境中运行脚本,它将自动加载您的.env
pipenv run spotifyconnector

要在此库的开发过程中添加新的依赖项

pipenv install --dev $package

要添加此库正确运行所需的依赖项,请将其添加到./setup.py中的install_requires部分,然后

pipenv install

要发布此包

python setup.py sdist bdist_wheel
twine upload dist/*

make publish

鸣谢

本代码灵感来源于wdr-okr中的代码,进行了扩展并在PyPi上发布。

项目详情


下载文件

下载适用于您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

spotifyconnector-0.8.2.tar.gz (10.4 kB 查看哈希)

上传时间 源代码

构建分发

spotifyconnector-0.8.2-py3-none-any.whl (10.1 kB 查看哈希)

上传时间 Python 3

支持