How to use the spotdl.internals function in spotdl

To help you get started, we’ve selected a few spotdl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ritiek / spotify-downloader / test / test_youtube_tools.py View on Github external
def filename_fixture(title_fixture):
    filename = internals.sanitize_title(title_fixture)
    return filename
github ritiek / spotify-downloader / spotdl / spotify_tools.py View on Github external
def fetch_albums_from_artist(artist_url, album_type=None):
    """
    This funcction returns all the albums from a give artist_url using the US
    market
    :param artist_url - spotify artist url
    :param album_type - the type of album to fetch (ex: single) the default is
                        all albums
    :param return - the album from the artist
    """

    # fetching artist's albums limitting the results to the US to avoid duplicate
    # albums from multiple markets
    artist_id = internals.extract_spotify_id(artist_url)
    results = spotify.artist_albums(artist_id, album_type=album_type, country="US")

    albums = results["items"]

    # indexing all pages of results
    while results["next"]:
        results = spotify.next(results)
        albums.extend(results["items"])

    return albums
github ritiek / spotify-downloader / spotdl / handle.py View on Github external
"is surrounded by curly braces. Possible formats: "
        "{}".format([internals.formats[x] for x in internals.formats]),
    )
    parser.add_argument(
        "--trim-silence",
        default=config["trim-silence"],
        help="remove silence from the start of the audio",
        action="store_true",
    )
    parser.add_argument(
        "-sf",
        "--search-format",
        default=config["search-format"],
        help="search format to search for on YouTube, each tag "
        "is surrounded by curly braces. Possible formats: "
        "{}".format([internals.formats[x] for x in internals.formats]),
    )
    parser.add_argument(
        "-dm",
        "--download-only-metadata",
        default=config["download-only-metadata"],
        help="download tracks only whose metadata is found",
        action="store_true",
    )
    parser.add_argument(
        "-d",
        "--dry-run",
        default=config["dry-run"],
        help="show only track title and YouTube URL, and then skip "
        "to the next track (if any)",
        action="store_true",
    )
github ritiek / spotify-downloader / spotdl / youtube_tools.py View on Github external
link = y.find("a")["href"][-11:]
            title = y.find("a")["title"]

            try:
                videotime = x.find("span", class_="video-time").get_text()
            except AttributeError:
                log.debug("Could not find video duration on YouTube, retrying..")
                return self.scrape(
                    bestmatch=bestmatch, tries_remaining=tries_remaining - 1
                )

            youtubedetails = {
                "link": link,
                "title": title,
                "videotime": videotime,
                "seconds": internals.get_sec(videotime),
            }
            videos.append(youtubedetails)

        if bestmatch:
            return self._best_match(videos)

        return videos
github ritiek / spotify-downloader / spotdl / handle.py View on Github external
import os

import spotdl
from spotdl import internals


_LOG_LEVELS_STR = ["INFO", "WARNING", "ERROR", "DEBUG"]

default_conf = {
    "spotify-downloader": {
        "no-remove-original": False,
        "manual": False,
        "no-metadata": False,
        "no-fallback-metadata": False,
        "avconv": False,
        "folder": internals.get_music_dir(),
        "overwrite": "prompt",
        "input-ext": ".m4a",
        "output-ext": ".mp3",
        "write-to": None,
        "trim-silence": False,
        "download-only-metadata": False,
        "dry-run": False,
        "music-videos-only": False,
        "no-spaces": False,
        "file-format": "{artist} - {track_name}",
        "search-format": "{artist} - {track_name} lyrics",
        "youtube-api-key": None,
        "skip": None,
        "write-successful": None,
        "log-level": "INFO",
        "spotify_client_id": "4fe3fecfe5334023a1472516cc99d805",