No description
Find a file
unknown a826a968bb feat: implement search-based playlist creation and robust text/JSON import
- main.py:
    - Added --import-json and --import-text for bulk playlist creation from local files.
    - Implemented search-based creation: providing a name instead of a URL now searches YouTube for a matching playlist.
    - Added --playlist-name to override the default title of any imported playlist.
    - Added --cookies-browser to bypass YouTube bot detection using browser cookies.
    - Improved import_text logic with intelligent Artist/Song detection for pop-punk genre.
- download_utils.py & youtube_utils.py:
    - Integrated support for --cookies-browser.
    - Added exponential backoff retry and random delays to downloads to minimize bot-detection triggers.
    - Improved validation of cookies.txt (Netscape header check).
- metadata_utils.py:
    - Implemented global rate-limiting (1 req/sec) and retries for MusicBrainz API calls to prevent 503 errors.
- clean_utils.py:
    - Expanded artist-first pattern recognition and improved extraction robustness.
- artist_name_mapping.json:
    - Significantly expanded the mapping table with common pop-punk and alternative artists.
2026-04-23 07:33:51 +01:00
tests refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
.gitignore refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
ARCHITECTURE.md refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
artist_name_mapping.json feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
cache_utils.py refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
clean_utils.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
config.json refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
config_utils.py feat: Integrate Last.fm for artist top tracks and enhance cleaning 2026-02-03 16:15:16 +00:00
constants.py Lot's off changes 2025-04-13 11:48:23 +01:00
cookies.txt feat: Refactor, add concurrency and improve error handling 2026-02-01 07:48:04 +00:00
download_utils.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
file_utils.py Lot's off changes 2025-04-13 11:48:23 +01:00
gemini_hint.md refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
jellyfin_api.py refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
lastfm_api.py refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
log.txt Minor fixes 2025-03-19 22:43:09 +00:00
main.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
metadata_utils.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
output.txt feat: Integrate Last.fm for artist top tracks and enhance cleaning 2026-02-03 16:15:16 +00:00
pytest.ini feat: Integrate Last.fm for artist top tracks and enhance cleaning 2026-02-03 16:15:16 +00:00
README.md docs: Update README.md and gemini_hint.md 2026-02-03 19:04:42 +00:00
requirements.txt refactor: improve metadata cleaning, add Last.fm similarity discovery, and implement persistent caching 2026-02-06 17:57:48 +00:00
song_name_mapping.json feat: Integrate Last.fm for artist top tracks and enhance cleaning 2026-02-03 16:15:16 +00:00
string_utils.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00
youtube_utils.py feat: implement search-based playlist creation and robust text/JSON import 2026-04-23 07:33:51 +01:00

Playlist Importer

A Python-based tool to import YouTube playlists into Jellyfin, with support for downloading missing songs, cleaning file names, adding metadata, and creating playlists from Last.fm data.


Table of Contents

  1. Features
  2. Prerequisites
  3. Setup
  4. Usage
  5. Configuration
  6. Troubleshooting
  7. Contributing
  8. License

Features

  • Import YouTube Playlists: Fetch and import YouTube playlists into Jellyfin.
  • Download Missing Songs: Automatically download missing songs from YouTube.
  • Clean File Names: Remove unwanted prefixes (e.g., NA - ) and content within parentheses or brackets.
  • Add Metadata: Fetch and add metadata (album, year, etc.) to audio files.
  • Jellyfin Integration: Seamlessly add songs to Jellyfin playlists.
  • Last.fm Integration:
    • Create playlists from an artist's top tracks.
    • Create playlists from top tracks by tag (e.g., "rock", "pop", "reggaeton").
    • Discover popular tags on Last.fm.

Prerequisites

Before using this project, ensure you have the following installed:

  • Python 3.8 or higher
  • FFmpeg (for audio processing)
  • Jellyfin Server (with API access)
  • Last.fm API Key (required for Last.fm features)

Setup

1. Clone the Repository

git clone http://192.168.0.56:3000/slava/playlist-importer.git
cd playlist-importer

2. Install Dependencies

Install the required Python packages:

pip install -r requirements.txt

3. Configure the Application

Copy the config.json.example to config.json and fill in your Jellyfin and Last.fm API credentials.

{
    "jellyfin": {
        "server_url": "http://JELLYFIN_SERVER_IP:8096",
        "api_key": "YOUR_JELLYFIN_API_KEY",
        "user_id": "YOUR_JELLYFIN_USER_ID"
    },
    "lastfm": {
        "api_key": "YOUR_LASTFM_API_KEY"
    },
    "download": {
        "output_dir": "downloaded_songs"
    }
}

Usage

Import a YouTube Playlist

To import a YouTube playlist into Jellyfin, run:

python main.py "YOUTUBE_PLAYLIST_URL"

Fetch Artist Top Tracks from Last.fm

Create a playlist of an artist's top tracks.

python main.py --artist-top-tracks "Artist Name" --limit 50

Fetch Top Tracks by Tag from Last.fm

Create a playlist of top tracks for a specific tag.

python main.py --top-tracks-by-tag "rock" --limit 100

List the most popular tags on Last.fm.

python main.py --popular-tags

Common Arguments

  • --download: Download any songs that are not found in your Jellyfin library.
  • --limit <number>: Specify the number of tracks to fetch from Last.fm (default is 30).
  • --ignore-cache: Ignores cached playlist data and fetches fresh data.
  • --clear-cache: Clears all cached data.

Configuration

artist_name_mapping.json

This file allows you to correct artist names that may differ between Last.fm and your Jellyfin library. For example, if Last.fm returns "Artist Name & The Band" but your library has "Artist Name", you can add a mapping:

{
    "artist name & the band": "Artist Name"
}

This helps improve the accuracy of song matching.


Troubleshooting

  • ModuleNotFoundError: Ensure you have installed the dependencies from requirements.txt and are running the script from the project's root directory.
  • FFmpeg Not Found: Make sure FFmpeg is installed and accessible in your system's PATH.
  • 401 Unauthorized from Jellyfin: Double-check your Jellyfin server URL, API key, and user ID in config.json.
  • Last.fm API Errors: Verify your Last.fm API key in config.json.