Skip to content
Snippets Groups Projects
Commit a11658eb authored by Robert Goldmann's avatar Robert Goldmann
Browse files

pretty printing and redirect errors to stderr

parent 73a6c37f
Branches
Tags
No related merge requests found
from __future__ import unicode_literals
import os
import sys
import googleapiclient.discovery
import googleapiclient.errors
import youtube_dl
VERSION = (2, 0, 0)
class MyLogger(object):
def debug(self, msg):
pass
......@@ -15,7 +19,7 @@ class MyLogger(object):
pass
def error(self, msg):
print(msg)
print(msg, file=sys.stderr)
def my_hook(d):
......@@ -35,6 +39,8 @@ class SaveMyPlaylist:
ILLEGAL_CHARS = ['NUL', '\',''//', ':', '*', '"', '<', '>', '|']
def __init__(self, apiKey, playlistId):
print('### SaveMyPlaylist v{} ###'.format('.'.join(str(i) for i in VERSION)))
print('=============================\n')
self.__apiKey = apiKey
self.__playlistId = playlistId
self.__youtubeApi = googleapiclient.discovery.build(self.API_NAME, self.API_VERSION, developerKey=self.__apiKey)
......@@ -130,6 +136,7 @@ if __name__ == '__main__':
API_KEY = 'AIzaSyD1cQOPzYDRe5pylXEFsQw6u-MaBSOX09Y'
PLAYLIST_ID = 'PL7F-5FkCMt0HRvF40L2704WhjJZf9G6SB'
DESTINATION_FOLDER = 'C:/Users/ROGO2/Desktop/123'
SKIP_DOWNLOAD = True
saveMyPlaylist = SaveMyPlaylist(API_KEY, PLAYLIST_ID)
saveMyPlaylist.download_items(DESTINATION_FOLDER, True)
saveMyPlaylist.download_items(DESTINATION_FOLDER, SKIP_DOWNLOAD)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment