Skip to content

plugins.soop: rewrite authentication #6321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2024

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Dec 3, 2024

Resolves #6320

@Infinitay please give this PR a quick test and report back with the results. This site requires a phone number when trying to register a new account, so I'm not able to test this myself as I'm surely not going to give them any of my personal data. Please also try purging the stored credentials, logging back in, and checking the stored auth credentials again. Thank you.
https://github.com/streamlink/streamlink/blob/master/CONTRIBUTING.md#pull-request-feedback


Instead of checking a list of specific/hardcoded cookies, this PR rewrites the auth logic by checking whether any cookies are available on the HTTP session (restored from the plugin cache) for the .sooplive.co.kr domain, and if that's the case, then it attempts to verify the cookies on GET https://afevent2.sooplive.co.kr/api/get_private_info.php, which apparently is what their website uses as API endpoint. If the JSON response includes an empty LOGIN_ID field, then the user is not authenticated. The endpoint apparently seems to always return status 200, but I'm not fully sure.

@bastimeyer bastimeyer added the plugin enhancement A new feature for a working Plugin label Dec 3, 2024
@bastimeyer bastimeyer force-pushed the plugins/soop/rewrite-auth branch from 08f6bec to c4f5858 Compare December 3, 2024 13:22
@bastimeyer bastimeyer added more info required Further information is requested restriction: account needed labels Dec 3, 2024
@Infinitay
Copy link

Thanks for working on this. I'm facing an issue:

(sl-6321) A:\folder>streamlink --loglevel=debug --output "{author} {id}.ts" --retry-streams 3 --retry-max 0 --hls-live-restart https://play.sooplive.co.kr/cooksuxtv best
[session][debug] Loading plugin: soop
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.7
[cli][debug] OpenSSL:    OpenSSL 3.0.15 3 Sep 2024
[cli][debug] Streamlink: 7.0.0+25.gc4f58582
[cli][debug] Dependencies:
[cli][debug]  certifi: 2024.8.30
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.3.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.21.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.3
[cli][debug]  trio: 0.27.0
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  urllib3: 2.2.3
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  url=https://play.sooplive.co.kr/cooksuxtv
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
[cli][debug]  --output={author} {id}.ts
[cli][debug]  --retry-streams=3.0
[cli][debug]  --retry-max=0
[cli][debug]  --hls-live-restart=True
[cli][debug]  --ffmpeg-ffmpeg=C:\ProgramData\chocolatey\bin\ffmpeg.exe
[cli][debug]  --soop-username=********
[cli][debug]  --soop-password=********
[cli][debug]  --twitch-disable-ads=True
[cli][debug]  --twitch-low-latency=True
[cli][debug]  --twitch-api-header=[('Authorization', 'OAuth <redacted>')]
[plugins.soop][debug] Restored cookies: AbroadVod, _ausa, _ausb, AbroadChk, _au, _au3rd, AuthTicket, BbsTicket, UserTicket, RDB, isBbs
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/cooksuxtv
[cli][error] Unable to validate response text: ValidationError(dict):
  Key 'LOGIN_ID' not found in <{'CHANNEL': {'IS_LOGIN': 1, 'LOGIN_ID': '<redacted_username>',...>
[cli][info] Waiting for streams, retrying every 3.0 second(s)
[cli][error] Unable to validate response text: ValidationError(dict):
  Key 'LOGIN_ID' not found in <{'CHANNEL': {'IS_LOGIN': 1, 'LOGIN_ID': '<redacted_username>',...>
[cli][error] Unable to validate response text: ValidationError(dict):
  Key 'LOGIN_ID' not found in <{'CHANNEL': {'IS_LOGIN': 1, 'LOGIN_ID': '<redacted_username>',...>
Interrupted! Exiting...

Guess it's because of this line and how LOGIN_ID is the inner property of the CHANNEL object.

@bastimeyer bastimeyer force-pushed the plugins/soop/rewrite-auth branch from c4f5858 to 5b241da Compare December 4, 2024 08:03
@Infinitay
Copy link

[plugins.soop][debug] Restored cookies: AbroadChk, _au, _au3rd, AuthTicket, BbsTicket, UserTicket, RDB, isBbs, AbroadVod, _ausa, _ausb
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/cooksuxtv
[plugins.soop][debug] Authentication using stored credentials was successful
[cli][info] Waiting for streams, retrying every 3.0 second(s)
[plugins.soop][debug] Authentication using stored credentials was successful
[plugins.soop][debug] Authentication using stored credentials was successful
[plugins.soop][debug] Authentication using stored credentials was successful
[plugins.soop][debug] Authentication using stored credentials was successful
Interrupted! Exiting...

LGTM Thank you

@bastimeyer
Copy link
Member Author

Please also try purging the stored credentials, logging back in, and checking the stored auth credentials again. Thank you.

@Infinitay
Copy link

Please also try purging the stored credentials, logging back in, and checking the stored auth credentials again. Thank you.

Sorry I completely skipped over that part. My mistake.

(sl-6321) A:\folder>streamlink --loglevel=debug --output "{author} {id}.ts" --retry-streams 3 --retry-max 0 --hls-live-restart --soop-purge-credentials https://play.sooplive.co.kr/cooksuxtv best
[session][debug] Loading plugin: soop
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.7
[cli][debug] OpenSSL:    OpenSSL 3.0.15 3 Sep 2024
[cli][debug] Streamlink: 7.0.0+25.g5b241da9
[cli][debug] Dependencies:
[cli][debug]  certifi: 2024.8.30
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.3.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.21.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.3
[cli][debug]  trio: 0.27.0
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  urllib3: 2.2.3
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  url=https://play.sooplive.co.kr/cooksuxtv
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
[cli][debug]  --output={author} {id}.ts
[cli][debug]  --retry-streams=3.0
[cli][debug]  --retry-max=0
[cli][debug]  --hls-live-restart=True
[cli][debug]  --ffmpeg-ffmpeg=C:\ProgramData\chocolatey\bin\ffmpeg.exe
[cli][debug]  --soop-username=********
[cli][debug]  --soop-password=********
[cli][debug]  --soop-purge-credentials=True
[cli][debug]  --twitch-disable-ads=True
[cli][debug]  --twitch-low-latency=True
[cli][debug]  --twitch-api-header=[('Authorization', 'OAuth <redacted>')]
[plugins.soop][debug] Restored cookies: UserTicket, RDB, isBbs, _ausa, _ausb, AbroadChk, _au, _au3rd, AuthTicket, BbsTicket, AbroadVod
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/cooksuxtv
[plugins.soop][info] All credentials were successfully removed
[plugins.soop][debug] Attempting to login using username and password
[plugins.soop][debug] Saved cookies: AbroadChk, AbroadVod, _au, _au3rd, _ausa, _ausb, AuthTicket, BbsTicket, UserTicket, isBbs, RDB, BbsSaveTicket
[plugins.soop][info] Login was successful
[cli][info] Waiting for streams, retrying every 3.0 second(s)
[plugins.soop][info] All credentials were successfully removed
[plugins.soop][debug] Attempting to login using username and password
[plugins.soop][debug] Saved cookies: AbroadChk, AbroadVod, _au, _au3rd, _ausa, _ausb, AuthTicket, BbsTicket, UserTicket, isBbs, RDB, BbsSaveTicket
[plugins.soop][info] Login was successful
[plugins.soop][info] All credentials were successfully removed
[plugins.soop][debug] Attempting to login using username and password
[plugins.soop][debug] Saved cookies: AbroadChk, AbroadVod, _au, _au3rd, _ausa, _ausb, AuthTicket, BbsTicket, UserTicket, isBbs, RDB, BbsSaveTicket
[plugins.soop][info] Login was successful
Interrupted! Exiting...

Seems to be working fine. It's up to you on how you want to implement the credentials purging while waiting for a stream - whether you want to to keeping purging the credentials as it's doing currently or not. Although, I expected passing in --soop-purge-credentials to work alone without a URL given this behavior, but that wasn't the case.

Just Purge

(sl-6321) A:\>streamlink --loglevel=debug --output "{author} {id}.ts" --retry-streams 3 --retry-max 0 --hls-live-restart --soop-purge-credentials
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.7
[cli][debug] OpenSSL:    OpenSSL 3.0.15 3 Sep 2024
[cli][debug] Streamlink: 7.0.0+25.g5b241da9
[cli][debug] Dependencies:
[cli][debug]  certifi: 2024.8.30
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.3.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.21.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.3
[cli][debug]  trio: 0.27.0
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  urllib3: 2.2.3
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
[cli][debug]  --output={author} {id}.ts
[cli][debug]  --retry-streams=3.0
[cli][debug]  --retry-max=0
[cli][debug]  --hls-live-restart=True
[cli][debug]  --ffmpeg-ffmpeg=C:\ProgramData\chocolatey\bin\ffmpeg.exe
[cli][debug]  --soop-username=********
[cli][debug]  --soop-password=********
[cli][debug]  --soop-purge-credentials=True
[cli][debug]  --twitch-disable-ads=True
[cli][debug]  --twitch-low-latency=True
[cli][debug]  --twitch-api-header=[('Authorization', 'OAuth <redacted>')]
usage: streamlink [OPTIONS] <URL> [STREAM]

Use -h/--help to see the available options or read the manual at https://streamlink.github.io/

To add on to what I was saying, I assumed that since the combination of --soop-purge-credentials --retry-max 0 will always purge credentials on each retry, that --soop-purge-credentials without a specified URL would work as is. Although, I guess this isn't expected behavior and would rather be better suited as a feature request.

@bastimeyer bastimeyer force-pushed the plugins/soop/rewrite-auth branch from 5b241da to 7dc98cc Compare December 5, 2024 07:30
@bastimeyer
Copy link
Member Author

credentials purging while waiting for a stream

This is a one-time operation which doesn't make sense when retrying streams. I've moved it to the plugin constructor now, so that it's actually only run once. You can give this update a try if you want, otherwise I'm going to merge later. Thanks.

that --soop-purge-credentials without a specified URL would work as is

No, a plugin first has to be matched/resolved in order for any plugin-arguments to be relevant. Without an input URL, no plugins are resolved and initialized.

@bastimeyer bastimeyer removed the more info required Further information is requested label Dec 5, 2024
@Infinitay
Copy link

Went ahead and tested it before I removed my conda env and it worked fine. Thanks again for your time and effort on this issue.

(sl-6321) A:\folder>streamlink --loglevel=debug --output "{author} {id}.ts" --retry-streams 3 --retry-max 0 --hls-live-restart --soop-purge-credentials https://play.sooplive.co.kr/cooksuxtv best
[session][debug] Loading plugin: soop
[cli][debug] OS:         Windows 10
[cli][debug] Python:     3.12.7
[cli][debug] OpenSSL:    OpenSSL 3.0.15 3 Sep 2024
[cli][debug] Streamlink: 7.0.0+25.g7dc98cc3
[cli][debug] Dependencies:
[cli][debug]  certifi: 2024.8.30
[cli][debug]  isodate: 0.7.2
[cli][debug]  lxml: 5.3.0
[cli][debug]  pycountry: 24.6.1
[cli][debug]  pycryptodome: 3.21.0
[cli][debug]  PySocks: 1.7.1
[cli][debug]  requests: 2.32.3
[cli][debug]  trio: 0.27.0
[cli][debug]  trio-websocket: 0.11.1
[cli][debug]  urllib3: 2.2.3
[cli][debug]  websocket-client: 1.8.0
[cli][debug] Arguments:
[cli][debug]  url=https://play.sooplive.co.kr/cooksuxtv
[cli][debug]  stream=['best']
[cli][debug]  --loglevel=debug
[cli][debug]  --player=C:\Program Files\DAUM\PotPlayer\PotPlayerMini64.exe
[cli][debug]  --output={author} {id}.ts
[cli][debug]  --retry-streams=3.0
[cli][debug]  --retry-max=0
[cli][debug]  --hls-live-restart=True
[cli][debug]  --ffmpeg-ffmpeg=C:\ProgramData\chocolatey\bin\ffmpeg.exe
[cli][debug]  --soop-username=********
[cli][debug]  --soop-password=********
[cli][debug]  --soop-purge-credentials=True
[cli][debug]  --twitch-disable-ads=True
[cli][debug]  --twitch-low-latency=True
[cli][debug]  --twitch-api-header=[('Authorization', 'OAuth <redacted>')]
[plugins.soop][debug] Restored cookies: AbroadChk, _au, _au3rd, AuthTicket, BbsTicket, AbroadVod, RDB, isBbs, _ausa, _ausb
[plugins.soop][info] All credentials were successfully removed
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/cooksuxtv
[plugins.soop][debug] Attempting to login using username and password
[plugins.soop][debug] Saved cookies: AbroadChk, AbroadVod, _au, _au3rd, _ausa, _ausb, AuthTicket, BbsTicket, UserTicket, isBbs, RDB, BbsSaveTicket
[plugins.soop][info] Login was successful
[cli][info] Waiting for streams, retrying every 3.0 second(s)
[plugins.soop][debug] Authentication using stored credentials was successful
[plugins.soop][debug] Authentication using stored credentials was successful
[plugins.soop][debug] Authentication using stored credentials was successful
Interrupted! Exiting...

@bastimeyer bastimeyer merged commit f3c3546 into streamlink:master Dec 5, 2024
23 checks passed
@bastimeyer bastimeyer deleted the plugins/soop/rewrite-auth branch December 5, 2024 07:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin enhancement A new feature for a working Plugin restriction: account needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

plugins.soop: Cached credentials not working after logging in with username/password
2 participants