Skip to content

Commit

Permalink
merge with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
SathyaBhat committed Feb 19, 2017
2 parents 182dfd6 + 4d19f44 commit 5839c35
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Pre-requisite: You need Python 3+

3. Create your YouTube API key & fetch the keys from [Google Developer Console](https://console.developers.google.com/apis/api/youtube/overview). Set the key as `YOUTUBE_DEV_KEY` environment variable as mentioned above.
4. Run the script using `spotify_dl`. spotify_dl accepts different parameters, for more details run `spotify_dl -h`.

For most users `spotify_dl -i spotify_URI -o download_directory` should do where

- `spotify_URI` is Spotify's unique identifier. You can get it from the 3-dot menu.
Expand Down
8 changes: 5 additions & 3 deletions spotify_dl/spotify.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from __future__ import unicode_literals
from spotify_dl.scaffold import *
import spotipy.util as util
import youtube_dl
import re
import os

import spotipy.util as util
import youtube_dl

from spotify_dl.scaffold import *


def authenticate():
"""Authenticates you to Spotify
Expand Down
11 changes: 6 additions & 5 deletions spotify_dl/spotify_dl.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/env python
import os
from logging import DEBUG
import argparse

import spotipy

from spotify_dl.scaffold import *
from spotify_dl.spotify import authenticate
Expand All @@ -12,9 +15,6 @@
from spotify_dl.spotify import extract_user_and_playlist_from_uri
from spotify_dl.spotify import get_playlist_name_from_id

import spotipy
import argparse


def spotify_dl():
parser = argparse.ArgumentParser(prog='spotify_dl')
Expand Down Expand Up @@ -60,9 +60,9 @@ def spotify_dl():
playlist = playlist_name(uri, sp)
else:
playlist = get_playlist_name_from_id(args.playlist, current_user_id, sp)

log.info("Saving songs to: {}".format(playlist))
download_directory = args.output[0] + '/' +playlist
download_directory = args.output[0] + '/' + playlist
# Check whether directory has a trailing slash or not
if len(download_directory) >= 0 and download_directory[-1] != '/':
download_directory += '/'
Expand All @@ -85,5 +85,6 @@ def spotify_dl():
if args.download is True:
download_songs(url, download_directory)


if __name__ == '__main__':
spotify_dl()
4 changes: 3 additions & 1 deletion spotify_dl/youtube.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from os import getenv

from googleapiclient.discovery import build

from spotify_dl.constants import YOUTUBE_API_SERVICE_NAME
from spotify_dl.constants import YOUTUBE_API_VERSION
from spotify_dl.constants import VIDEO
from spotify_dl.constants import YOUTUBE_VIDEO_URL
from spotify_dl.scaffold import log
from os import getenv


def fetch_youtube_url(search_term):
Expand Down

0 comments on commit 5839c35

Please sign in to comment.