Fixes #272 by refactoring global log to conventional global... (#358)

* Fixes #272 by refactoring global log to conventional global as used by logzero

* Remove unnecessary logger from download_single, which was a test case

* Remove unnecessary logger from main(), which was a test case
This commit is contained in:
Arryon Tijsma
2018-09-22 07:43:26 +02:00
committed by Ritiek Malhotra
parent 803a677167
commit 32c2ace96c
8 changed files with 12 additions and 13 deletions

View File

@@ -4,7 +4,6 @@ _log_format = ("%(color)s%(levelname)s:%(end_color)s %(message)s")
_formatter = logzero.LogFormatter(fmt=_log_format) _formatter = logzero.LogFormatter(fmt=_log_format)
# options # options
log = logzero.setup_logger(formatter=_formatter)
args = None args = None
# Apple has specific tags - see mutagen docs - # Apple has specific tags - see mutagen docs -

View File

@@ -1,6 +1,6 @@
import subprocess import subprocess
import os import os
from spotdl.const import log from logzero import logger as log
"""What are the differences and similarities between ffmpeg, libav, and avconv? """What are the differences and similarities between ffmpeg, libav, and avconv?

View File

@@ -1,8 +1,7 @@
import appdirs import appdirs
from logzero import logging as log
from spotdl import internals, const from spotdl import internals, const
log = const.log
import logging import logging
import yaml import yaml
import argparse import argparse

View File

@@ -1,9 +1,9 @@
import os import os
import sys import sys
from logzero import logger as log
from spotdl import const from spotdl import const
log = const.log
try: try:
from slugify import SLUG_OK, slugify from slugify import SLUG_OK, slugify

View File

@@ -2,7 +2,8 @@ from mutagen.easyid3 import EasyID3
from mutagen.id3 import ID3, TORY, TYER, TPUB, APIC, USLT, COMM from mutagen.id3 import ID3, TORY, TYER, TPUB, APIC, USLT, COMM
from mutagen.mp4 import MP4, MP4Cover from mutagen.mp4 import MP4, MP4Cover
from mutagen.flac import Picture, FLAC from mutagen.flac import Picture, FLAC
from spotdl.const import log, TAG_PRESET, M4A_TAG_PRESET from logzero import logger as log
from spotdl.const import TAG_PRESET, M4A_TAG_PRESET
import urllib.request import urllib.request

View File

@@ -8,9 +8,11 @@ from spotdl import convert
from spotdl import internals from spotdl import internals
from spotdl import spotify_tools from spotdl import spotify_tools
from spotdl import youtube_tools from spotdl import youtube_tools
from logzero import logging as log
from slugify import slugify from slugify import slugify
import spotipy import spotipy
import urllib.request import urllib.request
import logzero
import os import os
import sys import sys
import time import time
@@ -109,6 +111,7 @@ def download_list(text_file):
def download_single(raw_song, number=None): def download_single(raw_song, number=None):
""" Logic behind downloading a song. """ """ Logic behind downloading a song. """
if internals.is_youtube(raw_song): if internals.is_youtube(raw_song):
log.debug('Input song is a YouTube URL') log.debug('Input song is a YouTube URL')
content = youtube_tools.go_pafy(raw_song, meta_tags=None) content = youtube_tools.go_pafy(raw_song, meta_tags=None)
@@ -182,10 +185,8 @@ def main():
internals.filter_path(const.args.folder) internals.filter_path(const.args.folder)
youtube_tools.set_api_key() youtube_tools.set_api_key()
const.log = const.logzero.setup_logger(formatter=const._formatter, logzero.setup_default_logger(formatter=const._formatter, level=const.args.log_level)
level=const.args.log_level)
global log
log = const.log
log.debug('Python version: {}'.format(sys.version)) log.debug('Python version: {}'.format(sys.version))
log.debug('Platform: {}'.format(platform.platform())) log.debug('Platform: {}'.format(platform.platform()))
log.debug(pprint.pformat(const.args.__dict__)) log.debug(pprint.pformat(const.args.__dict__))

View File

@@ -1,9 +1,9 @@
import spotipy import spotipy
import spotipy.oauth2 as oauth2 import spotipy.oauth2 as oauth2
import lyricwikia import lyricwikia
from logzero import logger as log
from spotdl import internals from spotdl import internals
from spotdl.const import log
from slugify import slugify from slugify import slugify
from titlecase import titlecase from titlecase import titlecase

View File

@@ -1,6 +1,7 @@
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import urllib import urllib
import pafy import pafy
from logzero import logger as log
from spotdl import internals from spotdl import internals
from spotdl import const from spotdl import const
@@ -8,8 +9,6 @@ from spotdl import const
import os import os
import pprint import pprint
log = const.log
# Fix download speed throttle on short duration tracks # Fix download speed throttle on short duration tracks
# Read more on mps-youtube/pafy#199 # Read more on mps-youtube/pafy#199
pafy.g.opener.addheaders.append(('Range', 'bytes=0-')) pafy.g.opener.addheaders.append(('Range', 'bytes=0-'))