Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/lttkgp/metadata-extractor

Extract song metadata from YouTube links with Spotify API
https://github.com/lttkgp/metadata-extractor

hacktoberfest metadata-extraction spotify-api youtube

Last synced: 6 days ago
JSON representation

Extract song metadata from YouTube links with Spotify API

Awesome Lists containing this project

README

        

# metadata-extractor

Package to fetch music metadata from common Music APIs from a variety of data sources.

Currently, YouTube, YouTube Music and Spotify links are supported and data is fetched from Spotify APIs.

## Installation
```
pip install music-metadata-extractor
```
Ensure that the `.env` file for your project has all the environment variables defined in `.env.template`.

`SPOTIPY_CLIENT_ID` and `SPOTIPY_CLIENT_SECRET` can be obtained by creating a new app on the [Spotify Developer Dashboard](https://developer.spotify.com/dashboard/applications).

Similarly, you can get `GOOGLE_APPLICATION_CREDENTIALS` by creating a new project on the [Google Developer Console](https://console.developers.google.com/). Enable the `YouTube Data API` and create credentials. Use the API key you get in the `GOOGLE_APPLICATION_CREDENTIALS`.

## Usage

Example
```python
from music_metadata_extractor import SongData
data = SongData("https://www.youtube.com/watch?v=xwtdhWltSIg")
print(data)
```
The output is in the format
```
,
artists=[],
extraAttrs={'youtube': {'title': 'R.E.M. - Losing My Religion (Official Music Video)', 'views': '770535535', 'posted_date': datetime.datetime(2011, 7, 2, 0, 30, 31, tzinfo=tzutc()), 'converted_link': 'https://www.youtube.com/watch?v=xwtdhWltSIg'}}
)>

```
`music.youtube.com/watch` links and `open.spotify.com/track/` are also supported as inputs to `SongData`.

YouTube Music and Spotify links are converted to their equivalent YouTube links and returned in the `converted_link` field of the `extraAttrs` attribute.