|
13 | 13 | from ... import keys, methods |
14 | 14 | from ...api.parameters import Boolean, Direction, SortBy |
15 | 15 | from ...queries import V5Query as Qry |
| 16 | +from ...queries import GQLQuery as GQLQry |
16 | 17 | from ...queries import query |
17 | 18 |
|
18 | 19 |
|
@@ -80,20 +81,44 @@ def check_follows(user_id, channel_id): |
80 | 81 |
|
81 | 82 | # required scope: user_follows_edit |
82 | 83 | @query |
83 | | -def follow_channel(user_id, channel_id, notifications=Boolean.FALSE): |
84 | | - q = Qry('users/{user_id}/follows/channels/{channel_id}', method=methods.PUT) |
85 | | - q.add_urlkw(keys.USER_ID, user_id) |
86 | | - q.add_urlkw(keys.CHANNEL_ID, channel_id) |
87 | | - q.add_data(keys.NOTIFICATIONS, Boolean.validate(notifications), Boolean.FALSE) |
| 84 | +def follow_channel(channel_id, headers={}, notifications=False): |
| 85 | + data = [{ |
| 86 | + "operationName": "FollowButton_FollowUser", |
| 87 | + "variables": { |
| 88 | + "input": { |
| 89 | + "disableNotifications": notifications, |
| 90 | + "targetID": str(channel_id) |
| 91 | + } |
| 92 | + }, |
| 93 | + "extensions": { |
| 94 | + "persistedQuery": { |
| 95 | + "version": 1, |
| 96 | + "sha256Hash": "14319edb840c1dfce880dc64fa28a1f4eb69d821901e9e96eb9610d2e52b54f2" |
| 97 | + } |
| 98 | + } |
| 99 | + }] |
| 100 | + q = GQLQry('', headers=headers, data=data, use_token=False) |
88 | 101 | return q |
89 | 102 |
|
90 | 103 |
|
91 | 104 | # required scope: user_follows_edit |
92 | 105 | @query |
93 | | -def unfollow_channel(user_id, channel_id): |
94 | | - q = Qry('users/{user_id}/follows/channels/{channel_id}', method=methods.DELETE) |
95 | | - q.add_urlkw(keys.USER_ID, user_id) |
96 | | - q.add_urlkw(keys.CHANNEL_ID, channel_id) |
| 106 | +def unfollow_channel(channel_id, headers={}): |
| 107 | + data = [{ |
| 108 | + "operationName": "FollowButton_UnfollowUser", |
| 109 | + "variables": { |
| 110 | + "input": { |
| 111 | + "targetID": str(channel_id) |
| 112 | + } |
| 113 | + }, |
| 114 | + "extensions": { |
| 115 | + "persistedQuery": { |
| 116 | + "version": 1, |
| 117 | + "sha256Hash": "29783a1dac24124e02f7295526241a9f1476cd2f5ce1e394f93ea50c253d8628" |
| 118 | + } |
| 119 | + } |
| 120 | + }] |
| 121 | + q = GQLQry('', headers=headers, data=data, use_token=False) |
97 | 122 | return q |
98 | 123 |
|
99 | 124 |
|
|
0 commit comments