Skip to content

Commit

Permalink
Module examples and Bugs client accessibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Slyyxp committed Feb 16, 2022
1 parent 223fea5 commit 0f90a0e
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 8 deletions.
8 changes: 8 additions & 0 deletions examples/bugs_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from rsack.clients import bugs

client = bugs.Client() # Initialize client object
client.auth(username='', password='') # Authorize user

artist_response = client.get_meta(type='artist', id=80219706) # Make call for artist information using artist UID
album_response = client.get_meta(type='album', id=4071297) # Make call for album information using album UID
track_response = client.get_meta(type='track', id=6147328) # Make call for track information using track UID
10 changes: 10 additions & 0 deletions examples/genie_client.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from rsack.clients import genie

client = genie.Client() # Initialize client object
client.auth(username="", password="") # Authorize user

album = client.get_album(82525503) # Make call for album information using album UID
artist = client.get_artist(80006273) # Make call for artist information using artist UID
track = client.get_stream_meta(95970973) # Make call for stream information using track UID

print(track)
4 changes: 2 additions & 2 deletions rsack/bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ def __init__(self, type, id):
self.settings = Settings().Bugs()

# Create and authorize the client
self.client = bugs.Client(self.settings)
self.conn_info = self.client.auth()
self.client = bugs.Client()
self.conn_info = self.client.auth(username=self.settings['username'], password=self.settings['password'])
self.api_key = self.client.get_api_key()

# Grab the metadata
Expand Down
11 changes: 6 additions & 5 deletions rsack/clients/bugs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
from loguru import logger

class Client:
def __init__(self, settings):
def __init__(self):
self.session = requests.Session()
self.settings = settings
self.api_key = "b2de0fbe3380408bace96a5d1a76f800"
self.session.headers.update({
"User-Agent": "Mobile|Bugs|4.11.30|Android|5.1.1|SM-G965N|samsung|market",
"Host": "api.bugs.co.kr",
})

def auth(self):
def auth(self, username, password):
self.username = username
self.password = password
data = {
"device_id": "gwAHWlkOYX_T8Sl43N78GiaD6Sg_",
"passwd": self.settings['password'],
"userid": self.settings['username']
"passwd": password,
"userid": username
}
r = self.make_call("secure", "mbugs/3/login?", data=data)
if r['ret_code'] == 300:
Expand Down
4 changes: 3 additions & 1 deletion rsack/clients/genie.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_artist(self, id):
logger.critical("Failed to retrieve metadata")
return r

def get_stream_meta(self, id, q):
def get_stream_meta(self, id, q=None):
"""
:param id: Album ID
:param q: Album quality.
Expand All @@ -101,6 +101,8 @@ def get_stream_meta(self, id, q):
2 - 16bit FLAC
3 - 24bit FLAC
"""
if q is None:
q = '24bit'
data = {
"bitrate": q,
"dcd": self.dev_id,
Expand Down

0 comments on commit 0f90a0e

Please sign in to comment.