Skip to content

Commit

Permalink
use v2 models and remove usage of v1 models, and fix API (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosven authored Jul 12, 2023
1 parent 2a88a6a commit 798071e
Show file tree
Hide file tree
Showing 8 changed files with 351 additions and 437 deletions.
17 changes: 5 additions & 12 deletions fuo_kuwo/api.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging

import time
from pathlib import Path
from hashlib import md5

import requests
from requests.cookies import RequestsCookieJar
Expand Down Expand Up @@ -67,21 +67,14 @@ def __init__(self):
'Host': 'kuwo.cn',
}
self.mobi_headers = {'User-Agent': 'okhttp/3.10.0'}
self.get_cookie_token()
self.headers['csrf'] = self.token
random_str = '123456789'
self.headers['csrf'] = random_str
self.cookie = {'kw_token': random_str, 'Hm_token': random_str}
self.headers['Cross'] = md5(random_str.encode('utf-8')).hexdigest()
self._userid = ''
self._sid = ''
self._cookies = {}

def get_cookie_token(self):
"""get kuwo token & set cookie jar"""
token_uri = KuwoApi.HTTP_HOST + '/search/list?key=hello'
with requests.Session() as session:
response = session.get(token_uri, headers=self.headers)
token = response.cookies.get('kw_token')
self.token = token
self.cookie = response.cookies

def set_cookies(self, cookies):
if cookies:
self._cookies = cookies
Expand Down
346 changes: 0 additions & 346 deletions fuo_kuwo/models.py

This file was deleted.

5 changes: 3 additions & 2 deletions fuo_kuwo/pages/explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
PlaylistFilterProxyModel
from feeluown.gui.helpers import fetch_cover_wrapper, BgTransparentMixin

from fuo_kuwo.provider import provider


async def render(req, **kwargs):
app = req.ctx['app']
provider = app.library.get('kuwo')

playlists = await aio.run_fn(provider._user.get_rec_playlists)
playlists = await aio.run_fn(provider.current_user_rec_playlists)
view = ExploreView()
# view.daily_rec_btn.clicked.connect(
# lambda: app.browser.goto(page='/providers/kuwo/daily_recommendation'))
Expand Down
Loading

0 comments on commit 798071e

Please sign in to comment.