-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from romanin-rf/dev
Update 0.8.5
- Loading branch information
Showing
33 changed files
with
1,877 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
vkpymusic>=2.2.4 | ||
vbml>=1.1 | ||
vbml>=1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Client: | ||
def __init__(self, user_agent, client_id, client_secret): | ||
self.user_agent = user_agent | ||
self.client_id = client_id | ||
self.client_secret = client_secret | ||
|
||
|
||
KateMobile = Client( | ||
user_agent='KateMobileAndroid/56 lite-460 (Android 4.4.2; SDK 19; x86; unknown Android SDK built for x86; en)', | ||
client_id='2685278', | ||
client_secret='lxhD8OD7dMsqtXIm5IUY' | ||
) | ||
|
||
clients = {'Kate': KateMobile} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os, datetime, logging | ||
|
||
|
||
class bcolors: | ||
CRITICAL = "\033[95m" | ||
OKBLUE = "\033[94m" | ||
OKCYAN = "\033[96m" | ||
OKGREEN = "\033[92m" | ||
WARNING = "\033[93m" | ||
ERROR = "\033[91m" | ||
ENDC = "\033[0m" | ||
|
||
|
||
_log_format = "%(asctime)s | [%(name)s | (%(filename)s) .%(funcName)s(%(lineno)d)] [%(levelname)s] %(message)s" | ||
|
||
|
||
def get_file_handler(): | ||
file_path = f"logs/vkpymusic_{datetime.date.today()}.log" | ||
os.makedirs(os.path.dirname(file_path), exist_ok=True) | ||
|
||
file_handler = logging.FileHandler(file_path) | ||
file_handler.setLevel(logging.WARNING) | ||
file_handler.setFormatter(logging.Formatter(_log_format)) | ||
return file_handler | ||
|
||
|
||
def get_stream_handler(): | ||
stream_handler = logging.StreamHandler() | ||
stream_handler.setLevel(logging.INFO) | ||
stream_handler.setFormatter(logging.Formatter(_log_format)) | ||
return stream_handler | ||
|
||
|
||
def get_logger(name): | ||
logger = logging.getLogger(name) | ||
logger.setLevel(logging.INFO) | ||
logger.addHandler(get_file_handler()) | ||
logger.addHandler(get_stream_handler()) | ||
return logger |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
class Playlist: | ||
def __init__( | ||
self, title, description, photo, count, owner_id, playlist_id, access_key | ||
): | ||
self.title = title | ||
self.description = description | ||
self.photo = photo | ||
self.count = count | ||
self.owner_id = owner_id | ||
self.playlist_id = playlist_id | ||
self.access_key = access_key | ||
|
||
def __str__(self): | ||
return f"{self.title} ({self.count} tracks)" | ||
|
||
def to_dict(self) -> dict: | ||
return self.__dict__ | ||
|
||
@classmethod | ||
def from_json(cls, item): | ||
title = str(item["title"]) | ||
description = str(item["description"]) | ||
photo = str(item["photo"]["photo_1200"]) | ||
count = int(item["count"]) | ||
owner_id = int(item["owner_id"]) | ||
playlist_id = int(item["id"]) | ||
access_key = str(item["access_key"]) | ||
|
||
playlist = cls( | ||
title, description, photo, count, owner_id, playlist_id, access_key | ||
) | ||
return playlist |
Oops, something went wrong.