fuo-qqmusic 1.0.5__tar.gz → 1.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fuo-qqmusic might be problematic. Click here for more details.
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/PKG-INFO +12 -2
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/README.md +4 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/api.py +28 -1
- fuo_qqmusic-1.0.6/fuo_qqmusic/login.py +24 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/provider.py +50 -2
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/provider_ui.py +5 -32
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/PKG-INFO +13 -3
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/SOURCES.txt +3 -1
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/setup.py +1 -1
- fuo_qqmusic-1.0.6/tests/test_provider.py +26 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/__init__.py +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/assets/icon.svg +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/consts.py +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/excs.py +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic/schemas.py +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/dependency_links.txt +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/entry_points.txt +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/requires.txt +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/fuo_qqmusic.egg-info/top_level.txt +0 -0
- {fuo_qqmusic-1.0.5 → fuo_qqmusic-1.0.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: fuo_qqmusic
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: feeluown qqmusic plugin
|
|
5
5
|
Home-page: https://github.com/feeluown/feeluown-qqmusic
|
|
6
6
|
Author: Cosven
|
|
@@ -13,3 +13,13 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.8
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Requires-Dist: feeluown>=4.1.3
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: marshmallow>=3.0
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: keywords
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: summary
|
|
@@ -58,7 +58,7 @@ class API(object):
|
|
|
58
58
|
Please http capture request from (mobile) qqmusic mobile web page
|
|
59
59
|
"""
|
|
60
60
|
|
|
61
|
-
def __init__(self, timeout=
|
|
61
|
+
def __init__(self, timeout=2):
|
|
62
62
|
# TODO: 暂时无脑统一一个 timeout
|
|
63
63
|
# 正确的应该是允许不同接口有不同的超时时间
|
|
64
64
|
self._timeout = timeout
|
|
@@ -518,6 +518,33 @@ class API(object):
|
|
|
518
518
|
js = self.rpc(payload)
|
|
519
519
|
return js['songlist']['data']['tracks']
|
|
520
520
|
|
|
521
|
+
def get_diss_info(self, dissid, offset=0, limit=50):
|
|
522
|
+
"""获取歌单的详情
|
|
523
|
+
|
|
524
|
+
这是一种特殊的歌单,它的内容是动态的,由官方生成。比如“百万收藏”。
|
|
525
|
+
|
|
526
|
+
:param dissid: int, 举个例子 211111 是百万收藏。
|
|
527
|
+
:return: 参考 fixtures/get_diss_info.json
|
|
528
|
+
"""
|
|
529
|
+
payload = {
|
|
530
|
+
'req': {
|
|
531
|
+
"module": "music.srfDissInfo.aiDissInfo",
|
|
532
|
+
"method":"uniform_get_Dissinfo",
|
|
533
|
+
"param": {
|
|
534
|
+
"disstid":dissid,
|
|
535
|
+
"userinfo":1, # 不懂啥意思
|
|
536
|
+
"tag":1, # 不懂啥意思
|
|
537
|
+
"orderlist":1,
|
|
538
|
+
"song_begin": offset,
|
|
539
|
+
"song_num": limit,
|
|
540
|
+
"onlysonglist":0,
|
|
541
|
+
"enc_host_uin":"" # 注:即使登录了,这个也是空
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
js = self.rpc(payload)
|
|
546
|
+
return js['req']['data']
|
|
547
|
+
|
|
521
548
|
def get_song_url(self, song_mid):
|
|
522
549
|
uin = self._uin
|
|
523
550
|
songvkey = str(random.random()).replace("0.", "")
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
|
|
4
|
+
from feeluown.consts import DATA_DIR
|
|
5
|
+
|
|
6
|
+
USER_INFO_FILE = DATA_DIR + '/qqmusic_user_info.json'
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def read_cookies():
|
|
10
|
+
if os.path.exists(USER_INFO_FILE):
|
|
11
|
+
# if the file is broken, just raise error
|
|
12
|
+
with open(USER_INFO_FILE) as f:
|
|
13
|
+
return json.load(f).get('cookies', None)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def write_cookies(user, cookies):
|
|
17
|
+
js = {
|
|
18
|
+
'identifier': user.identifier,
|
|
19
|
+
'name': user.name,
|
|
20
|
+
'cookies': cookies
|
|
21
|
+
}
|
|
22
|
+
with open(USER_INFO_FILE, 'w') as f:
|
|
23
|
+
json.dump(js, f, indent=2)
|
|
24
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import logging
|
|
2
|
-
from typing import List, Optional, Protocol
|
|
2
|
+
from typing import List, Optional, Protocol, Tuple
|
|
3
3
|
from feeluown.excs import ModelNotFound
|
|
4
4
|
from feeluown.library import (
|
|
5
5
|
AbstractProvider,
|
|
@@ -26,10 +26,13 @@ from feeluown.library import (
|
|
|
26
26
|
SimpleSearchResult,
|
|
27
27
|
SearchType,
|
|
28
28
|
ModelType,
|
|
29
|
+
UserModel,
|
|
29
30
|
)
|
|
30
31
|
from feeluown.media import Media, Quality
|
|
31
32
|
from feeluown.utils.reader import create_reader, SequentialReader
|
|
32
33
|
from .api import API
|
|
34
|
+
from .login import read_cookies
|
|
35
|
+
from .excs import QQIOError
|
|
33
36
|
|
|
34
37
|
|
|
35
38
|
logger = logging.getLogger(__name__)
|
|
@@ -79,6 +82,31 @@ class QQProvider(AbstractProvider, ProviderV2):
|
|
|
79
82
|
def name(self):
|
|
80
83
|
return "QQ 音乐"
|
|
81
84
|
|
|
85
|
+
def auto_login(self):
|
|
86
|
+
cookies = read_cookies()
|
|
87
|
+
user, err = self.try_get_user_from_cookies(cookies)
|
|
88
|
+
if user:
|
|
89
|
+
self.auth(user)
|
|
90
|
+
else:
|
|
91
|
+
logger.info(f'Auto login failed: {err}')
|
|
92
|
+
|
|
93
|
+
def try_get_user_from_cookies(self, cookies) -> Tuple[Optional[UserModel], str]:
|
|
94
|
+
if not cookies: # is None or empty
|
|
95
|
+
return None, 'empty cookies'
|
|
96
|
+
|
|
97
|
+
uin = provider.api.get_uin_from_cookies(cookies)
|
|
98
|
+
if uin is None:
|
|
99
|
+
return None, "can't extract user info from cookies"
|
|
100
|
+
|
|
101
|
+
provider.api.set_cookies(cookies)
|
|
102
|
+
# try to extract current user
|
|
103
|
+
try:
|
|
104
|
+
user = provider.user_get(uin)
|
|
105
|
+
except QQIOError:
|
|
106
|
+
provider.api.set_cookies(None)
|
|
107
|
+
return None, 'get user info with cookies failed, expired cookies?'
|
|
108
|
+
return user, ''
|
|
109
|
+
|
|
82
110
|
def use_model_v2(self, mtype):
|
|
83
111
|
return mtype in (
|
|
84
112
|
ModelType.song,
|
|
@@ -259,6 +287,27 @@ class QQProvider(AbstractProvider, ProviderV2):
|
|
|
259
287
|
pl["logo"] = pl["cover"]
|
|
260
288
|
return [_deserialize(playlist, QQPlaylistSchema) for playlist in playlists]
|
|
261
289
|
|
|
290
|
+
def rec_list_daily_songs(self):
|
|
291
|
+
# TODO: cache API result
|
|
292
|
+
feed = self.api.get_recommend_feed()
|
|
293
|
+
card = None
|
|
294
|
+
for shelf_ in feed['v_shelf']:
|
|
295
|
+
if 'moduleID' not in shelf_['extra_info']:
|
|
296
|
+
for batch in shelf_['v_niche']:
|
|
297
|
+
for card in batch['v_card']:
|
|
298
|
+
if (
|
|
299
|
+
card['extra_info'].get('moduleID', '').startswith('recforyou')
|
|
300
|
+
and card['jumptype'] == 10014 # 10014->playlist
|
|
301
|
+
):
|
|
302
|
+
card = card
|
|
303
|
+
break
|
|
304
|
+
if card is None:
|
|
305
|
+
logger.warning("No daily songs found")
|
|
306
|
+
return []
|
|
307
|
+
playlist_id = card['id']
|
|
308
|
+
playlist = self.playlist_get(playlist_id)
|
|
309
|
+
return self.playlist_create_songs_rd(playlist).readall()
|
|
310
|
+
|
|
262
311
|
def rec_list_daily_playlists(self):
|
|
263
312
|
# TODO: cache API result
|
|
264
313
|
feed = self.api.get_recommend_feed()
|
|
@@ -273,7 +322,6 @@ class QQProvider(AbstractProvider, ProviderV2):
|
|
|
273
322
|
playlists = []
|
|
274
323
|
for batch in shelf['v_niche']:
|
|
275
324
|
for card in batch['v_card']:
|
|
276
|
-
print(card['title'], card['jumptype'])
|
|
277
325
|
if card['jumptype'] == 10014: # 10014->playlist
|
|
278
326
|
playlists.append(
|
|
279
327
|
PlaylistModel(identifier=str(card['id']),
|
|
@@ -11,20 +11,11 @@ from feeluown.app.gui_app import GuiApp
|
|
|
11
11
|
|
|
12
12
|
from .provider import provider
|
|
13
13
|
from .excs import QQIOError
|
|
14
|
+
from .login import read_cookies, write_cookies
|
|
14
15
|
|
|
15
16
|
logger = logging.getLogger(__name__)
|
|
16
17
|
|
|
17
18
|
|
|
18
|
-
USER_INFO_FILE = DATA_DIR + '/qqmusic_user_info.json'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def read_cookies():
|
|
22
|
-
if os.path.exists(USER_INFO_FILE):
|
|
23
|
-
# if the file is broken, just raise error
|
|
24
|
-
with open(USER_INFO_FILE) as f:
|
|
25
|
-
return json.load(f).get('cookies', None)
|
|
26
|
-
|
|
27
|
-
|
|
28
19
|
class ProviderUI(AbstractProviderUi):
|
|
29
20
|
def __init__(self, app: GuiApp):
|
|
30
21
|
self._app = app
|
|
@@ -72,31 +63,13 @@ class LoginDialog(CookiesLoginDialog):
|
|
|
72
63
|
provider._user = user
|
|
73
64
|
|
|
74
65
|
async def user_from_cookies(self, cookies):
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
uin = provider.api.get_uin_from_cookies(cookies)
|
|
79
|
-
if uin is None:
|
|
80
|
-
raise InvalidCookies("can't extract user info from cookies")
|
|
81
|
-
|
|
82
|
-
provider.api.set_cookies(cookies)
|
|
83
|
-
# try to extract current user
|
|
84
|
-
try:
|
|
85
|
-
user = await run_fn(provider.user_get, uin)
|
|
86
|
-
except QQIOError:
|
|
87
|
-
provider.api.set_cookies(None)
|
|
88
|
-
raise InvalidCookies('get user info with cookies failed, expired cookies?')
|
|
89
|
-
else:
|
|
66
|
+
user, err = await run_fn(provider.try_get_user_from_cookies, cookies)
|
|
67
|
+
if user:
|
|
90
68
|
return user
|
|
69
|
+
raise InvalidCookies(err)
|
|
91
70
|
|
|
92
71
|
def load_user_cookies(self):
|
|
93
72
|
return read_cookies()
|
|
94
73
|
|
|
95
74
|
def dump_user_cookies(self, user, cookies):
|
|
96
|
-
|
|
97
|
-
'identifier': user.identifier,
|
|
98
|
-
'name': user.name,
|
|
99
|
-
'cookies': cookies
|
|
100
|
-
}
|
|
101
|
-
with open(USER_INFO_FILE, 'w') as f:
|
|
102
|
-
json.dump(js, f, indent=2)
|
|
75
|
+
write_cookies(user, cookies)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
2
|
-
Name:
|
|
3
|
-
Version: 1.0.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fuo_qqmusic
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: feeluown qqmusic plugin
|
|
5
5
|
Home-page: https://github.com/feeluown/feeluown-qqmusic
|
|
6
6
|
Author: Cosven
|
|
@@ -13,3 +13,13 @@ Classifier: Programming Language :: Python :: 3.7
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.8
|
|
14
14
|
Classifier: Programming Language :: Python :: 3.9
|
|
15
15
|
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Requires-Dist: feeluown>=4.1.3
|
|
17
|
+
Requires-Dist: requests
|
|
18
|
+
Requires-Dist: marshmallow>=3.0
|
|
19
|
+
Dynamic: author
|
|
20
|
+
Dynamic: author-email
|
|
21
|
+
Dynamic: classifier
|
|
22
|
+
Dynamic: home-page
|
|
23
|
+
Dynamic: keywords
|
|
24
|
+
Dynamic: requires-dist
|
|
25
|
+
Dynamic: summary
|
|
@@ -4,6 +4,7 @@ fuo_qqmusic/__init__.py
|
|
|
4
4
|
fuo_qqmusic/api.py
|
|
5
5
|
fuo_qqmusic/consts.py
|
|
6
6
|
fuo_qqmusic/excs.py
|
|
7
|
+
fuo_qqmusic/login.py
|
|
7
8
|
fuo_qqmusic/provider.py
|
|
8
9
|
fuo_qqmusic/provider_ui.py
|
|
9
10
|
fuo_qqmusic/schemas.py
|
|
@@ -13,4 +14,5 @@ fuo_qqmusic.egg-info/dependency_links.txt
|
|
|
13
14
|
fuo_qqmusic.egg-info/entry_points.txt
|
|
14
15
|
fuo_qqmusic.egg-info/requires.txt
|
|
15
16
|
fuo_qqmusic.egg-info/top_level.txt
|
|
16
|
-
fuo_qqmusic/assets/icon.svg
|
|
17
|
+
fuo_qqmusic/assets/icon.svg
|
|
18
|
+
tests/test_provider.py
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import os
|
|
3
|
+
from unittest.mock import patch
|
|
4
|
+
|
|
5
|
+
import pytest
|
|
6
|
+
|
|
7
|
+
from fuo_qqmusic import provider
|
|
8
|
+
from fuo_qqmusic.api import API
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def _read_json_fixture(path):
|
|
12
|
+
path = os.path.join('data/fixtures', path)
|
|
13
|
+
with open(path, 'r', encoding='utf-8') as f:
|
|
14
|
+
data = json.load(f)
|
|
15
|
+
return data
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
@pytest.fixture
|
|
19
|
+
def album_3913679():
|
|
20
|
+
return _read_json_fixture('album_3913679.json')
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def test_provider_album_get(album_3913679):
|
|
24
|
+
patch.object(API, 'album_detail', return_value=album_3913679)
|
|
25
|
+
album = provider.album_get('3913679')
|
|
26
|
+
assert album.identifier == '3913679'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|