Exemplo n.º 1
0
"""Define functions related to getting tags."""

import itunespy
from ytmdl.stringutils import (remove_multiple_spaces, remove_punct,
                               compute_jaccard, remove_stopwords,
                               check_keywords)
from ytmdl import gaana, logger, defaults, saavn
from unidecode import unidecode

logger = logger.Logger('metadata')


def _logger_provider_error(exception, name):
    """Show error if providers throw an error"""
    logger.debug('{}'.format(exception))
    logger.error("Something went wrong with {}. The program will continue with"
                 "the other providers. Please check '{}' for more details.\
            ".format(name, logger.get_log_file()))


def get_from_itunes(SONG_NAME):
    """Try to download the metadata using itunespy."""
    # Try to get the song data from itunes
    try:
        SONG_INFO = itunespy.search_track(SONG_NAME)
        # Before returning convert all the track_time values to minutes.
        for song in SONG_INFO:
            song.track_time = round(song.track_time / 60000, 2)
        return SONG_INFO
    except Exception as e:
        _logger_provider_error(e, 'iTunes')
Exemplo n.º 2
0
from colorama import Fore, Style
from mutagen.id3 import (ID3, APIC, TIT2, TPE1, TALB, TCON, TRCK, TYER,
                         PictureType)
from mutagen.mp3 import MP3
from mutagen.mp4 import MP4, MP4Cover
from mutagen import File
from mutagen.flac import Picture
from base64 import b64encode
import requests
import os

from ytmdl import prepend, defaults, logger
from ytmdl.meta import preconfig
# import traceback

logger = logger.Logger("song")

# ----------------------cover--------------------


def dwCover(song):
    """Download the song cover img from itunes."""
    # Try to download the cover art as cover.jpg in temp
    logger.info("Preparing the album cover")
    try:
        imgURL = song.artwork_url_100

        # Check if the passed imgURL is a local file
        # this is possible if the metadata was entered manually.
        imgURL = os.path.expanduser(imgURL)
        if os.path.exists(imgURL):
Exemplo n.º 3
0
"""All directory handling definitions."""

import os
import glob
import shutil
from ytmdl import defaults, logger

logger = logger.Logger("Dir")


def cleanup(TRACK_INFO, index, datatype):
    """Move the song from temp to $HOME/Music dir."""
    try:
        SONG = glob.glob(
            os.path.join(defaults.DEFAULT.SONG_TEMP_DIR,
                         '*{}'.format(datatype)))
        SONG = SONG[0]

        SONG_NAME = os.path.basename(SONG)

        DIR = defaults.DEFAULT.SONG_DIR

        # Check if DIR has $ in its path
        # If it does then make those folders accordingly

        if '$' in DIR:
            DIR, name = make_custom_dir(DIR, TRACK_INFO[index])

            if name is not None:
                os.rename(SONG, name + '.mp3')
                SONG_NAME = name + '.mp3'