fuo-qqmusic 1.0.6__py3-none-any.whl → 1.0.7__py3-none-any.whl

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/api.py CHANGED
@@ -8,6 +8,7 @@ import math
8
8
  import json
9
9
  import random
10
10
  import time
11
+ from enum import Enum
11
12
 
12
13
  import requests
13
14
  from .excs import QQIOError
@@ -717,5 +718,85 @@ class API(object):
717
718
  return 'http://isure.stream.qqmusic.qq.com/{}'.format(midurlinfo[0]['purl'])
718
719
  return ''
719
720
 
721
+ class DislikeListType(Enum):
722
+ singer = 2
723
+ song = 3
724
+ _style_unsupported = 4 # TODO: 这是什么?似乎是不喜欢的风格列表,不确定,暂时不支持
725
+
726
+ def get_dislike_list(self, page=1, type_=DislikeListType.song, last_id=0):
727
+ payload = {
728
+ "req_0": {
729
+ "module": "music.feedback.FeedbackBlack",
730
+ "method": "GetDislikeList",
731
+ "param": {
732
+ "Cmd": type_.value,
733
+ "Page": page,
734
+ "SongLastid": last_id if type_ == API.DislikeListType.song else 0,
735
+ "SingersLastid": (
736
+ last_id if type_ == API.DislikeListType.singer else 0
737
+ ),
738
+ },
739
+ },
740
+ }
741
+ js = self.rpc(payload)
742
+ if type_ == API.DislikeListType.song:
743
+ return js["req_0"]["data"]["Songs"]
744
+ elif type_ == API.DislikeListType.singer:
745
+ return js["req_0"]["data"]["Singers"]
746
+ else:
747
+ raise QQIOError(f"Unknown dislike list type: {type_}")
748
+
749
+ def add_to_dislike_list(self, items, type_=DislikeListType.song):
750
+ req_param = {
751
+ "Singers": [],
752
+ "Songs": [],
753
+ "Styles": [],
754
+ "OnlyAdd": 1,
755
+ }
756
+ if type_ == API.DislikeListType.song:
757
+ req_param["Songs"] = items
758
+ elif type_ == API.DislikeListType.singer:
759
+ req_param["Singers"] = items
760
+ else:
761
+ raise QQIOError(f"Unknown dislike list type: {type_}")
762
+
763
+ payload = {
764
+ "req_0": {
765
+ "module": "music.feedback.FeedbackBlack",
766
+ "method": "AddDislike",
767
+ "param": req_param,
768
+ },
769
+ }
770
+ js = self.rpc(payload)
771
+ # Response example, {'code': 0, 'data': {'Retcode': 0, 'Msg': '', 'Token': ''}}
772
+ CodeShouldBe0.check(js['req_0'])
773
+ return js['req_0']['data']
774
+
775
+ def remove_from_dislike_list(self, items, type_=DislikeListType.song):
776
+ req_param = {
777
+ "Singers": [],
778
+ "Songs": [],
779
+ "Styles": [],
780
+ "OnlyAdd": 0,
781
+ }
782
+ if type_ == API.DislikeListType.song:
783
+ req_param["Songs"] = items
784
+ elif type_ == API.DislikeListType.singer:
785
+ req_param["Singers"] = items
786
+ else:
787
+ raise QQIOError(f"Unknown dislike list type: {type_}")
788
+
789
+ payload = {
790
+ "req_0": {
791
+ "module": "music.feedback.FeedbackBlack",
792
+ "method": "CancelDislike",
793
+ "param": req_param,
794
+ },
795
+ }
796
+ js = self.rpc(payload)
797
+ CodeShouldBe0.check(js)
798
+ CodeShouldBe0.check(js['req_0'])
799
+ return js['req_0']['data']
800
+
720
801
 
721
802
  api = API()
fuo_qqmusic/provider.py CHANGED
@@ -23,12 +23,17 @@ from feeluown.library import (
23
23
  SupportsPlaylistGet,
24
24
  SupportsPlaylistSongsReader,
25
25
  SupportsRecACollectionOfSongs,
26
+ SupportsCurrentUserDislikeSongsReader,
27
+ SupportsCurrentUserDislikeAddSong,
28
+ SupportsCurrentUserDislikeRemoveSong,
29
+ SupportsCurrentUserChanged,
26
30
  SimpleSearchResult,
27
31
  SearchType,
28
32
  ModelType,
29
33
  UserModel,
30
34
  )
31
35
  from feeluown.media import Media, Quality
36
+ from feeluown.utils.dispatch import Signal
32
37
  from feeluown.utils.reader import create_reader, SequentialReader
33
38
  from .api import API
34
39
  from .login import read_cookies
@@ -53,6 +58,9 @@ class Supports(
53
58
  SupportsPlaylistSongsReader,
54
59
  SupportsRecACollectionOfSongs,
55
60
  SupportsAlbumSongsReader,
61
+ SupportsCurrentUserDislikeSongsReader,
62
+ SupportsCurrentUserDislikeAddSong,
63
+ SupportsCurrentUserDislikeRemoveSong,
56
64
  Protocol,
57
65
  ):
58
66
  pass
@@ -70,6 +78,7 @@ class QQProvider(AbstractProvider, ProviderV2):
70
78
  def __init__(self):
71
79
  super().__init__()
72
80
  self.api = API()
81
+ self.current_user_changed = Signal()
73
82
 
74
83
  def _(self) -> Supports:
75
84
  return self
@@ -89,6 +98,7 @@ class QQProvider(AbstractProvider, ProviderV2):
89
98
  self.auth(user)
90
99
  else:
91
100
  logger.info(f'Auto login failed: {err}')
101
+ self.current_user_changed.emit(user)
92
102
 
93
103
  def try_get_user_from_cookies(self, cookies) -> Tuple[Optional[UserModel], str]:
94
104
  if not cookies: # is None or empty
@@ -417,6 +427,35 @@ class QQProvider(AbstractProvider, ProviderV2):
417
427
  data_songs = self.api.song_similar(int(song.identifier))
418
428
  return [_deserialize(data_song, QQSongSchema) for data_song in data_songs]
419
429
 
430
+ def current_user_dislike_create_songs_rd(self):
431
+ user = self.get_current_user()
432
+ if user is None:
433
+ return create_reader([])
434
+ # FIXME: 如果用户的黑名单歌曲数量较多的话,这样处理则是不够的
435
+ items = self.api.get_dislike_list(1, API.DislikeListType.song, 0)
436
+ songs = []
437
+ for item in items:
438
+ name = item['Name']
439
+ title, artists_name = name.split(' - ')
440
+ song = BriefSongModel(
441
+ source=SOURCE,
442
+ identifier=item['ID'],
443
+ title=title,
444
+ artists_name=artists_name,
445
+ )
446
+ songs.append(song)
447
+ return create_reader(songs)
448
+
449
+ def current_user_dislike_add_song(self, song):
450
+ items = [{'ID': song.identifier}]
451
+ js = self.api.add_to_dislike_list(items, API.DislikeListType.song)
452
+ return js.get('Retcode') == 0
453
+
454
+ def current_user_dislike_remove_song(self, song):
455
+ items = [{'ID': song.identifier}]
456
+ js = self.api.remove_from_dislike_list(items, API.DislikeListType.song)
457
+ return js.get('Retcode') == 0
458
+
420
459
 
421
460
  def _deserialize(data, schema_cls):
422
461
  schema = schema_cls()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fuo_qqmusic
3
- Version: 1.0.6
3
+ Version: 1.0.7
4
4
  Summary: feeluown qqmusic plugin
5
5
  Home-page: https://github.com/feeluown/feeluown-qqmusic
6
6
  Author: Cosven
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.9
15
15
  Classifier: Programming Language :: Python :: 3 :: Only
16
16
  Requires-Dist: feeluown>=4.1.3
17
17
  Requires-Dist: requests
18
- Requires-Dist: marshmallow>=3.0
18
+ Requires-Dist: marshmallow<4.0.0,>=3.0
19
19
  Dynamic: author
20
20
  Dynamic: author-email
21
21
  Dynamic: classifier
@@ -1,14 +1,14 @@
1
1
  fuo_qqmusic/__init__.py,sha256=YxZHAp5Qaye5B5V8GBPyxqnEUe-FcwUv6TiF_29qBEs,537
2
- fuo_qqmusic/api.py,sha256=bFgr9eyRMrBhsQC8qR1sJ5SN616tdn06eXG6igZ6_ms,24587
2
+ fuo_qqmusic/api.py,sha256=yDT6iyq9ZdkRQkqDI96uFE3ctbh7HseUU8NVsuu3jBM,27381
3
3
  fuo_qqmusic/consts.py,sha256=9VFc9yE6z6c0IzK03PQTEO0JqgXi37RahEvZRP-A4Dk,185
4
4
  fuo_qqmusic/excs.py,sha256=SBcER_wESjvui6a0Li1dX5utep4ouDS7HaTXqXPOQiA,160
5
5
  fuo_qqmusic/login.py,sha256=zNPPncKl1Pr8uYBbLrdPlVJyKBsNfS2FotRfn9l3LEA,542
6
- fuo_qqmusic/provider.py,sha256=LqFB18PtXVBVFl2SfDoaQea6R4aq16My9PGrhhLotPg,17478
6
+ fuo_qqmusic/provider.py,sha256=QUw5VvLaKodVVaKp2lPuSm8z1edXy5qUdmlzpE5Ldds,19025
7
7
  fuo_qqmusic/provider_ui.py,sha256=K70BjKvlx4h6gVYqeHOZhP68nnUWH2_mFbUK3jjvJ5U,2366
8
8
  fuo_qqmusic/schemas.py,sha256=Sbka-YuK3UTn26CbfwOb0ZfB6XmiJHW-ibCLThj49VQ,12128
9
9
  fuo_qqmusic/assets/icon.svg,sha256=o48VTiHroJU6S2g8LbxfnK25G2QW3d1XtQZKoL3ZMGA,1216
10
- fuo_qqmusic-1.0.6.dist-info/METADATA,sha256=nhPvAwYN2IzTfRbkBivKvgsaZtiCZroqPKIdfhZZsRc,803
11
- fuo_qqmusic-1.0.6.dist-info/WHEEL,sha256=0CuiUZ_p9E4cD6NyLD6UG80LBXYyiSYZOKDm5lp32xk,91
12
- fuo_qqmusic-1.0.6.dist-info/entry_points.txt,sha256=XUL7UwcsLZEuEbBJIcsFemC3BiYb7dSTiXB9r6SJ5zY,39
13
- fuo_qqmusic-1.0.6.dist-info/top_level.txt,sha256=Qn_g3dRwtoVZgVPZ9uRehspXi62T-E1x9_kLIdYFic4,12
14
- fuo_qqmusic-1.0.6.dist-info/RECORD,,
10
+ fuo_qqmusic-1.0.7.dist-info/METADATA,sha256=U6tM7hrztEL-AjtHR_R2U-MkOrPauHrgc54LemZGj8g,810
11
+ fuo_qqmusic-1.0.7.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
12
+ fuo_qqmusic-1.0.7.dist-info/entry_points.txt,sha256=XUL7UwcsLZEuEbBJIcsFemC3BiYb7dSTiXB9r6SJ5zY,39
13
+ fuo_qqmusic-1.0.7.dist-info/top_level.txt,sha256=Qn_g3dRwtoVZgVPZ9uRehspXi62T-E1x9_kLIdYFic4,12
14
+ fuo_qqmusic-1.0.7.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.3.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5