Skip to content

plugins.soop: refactor plugin and fix issues #6257

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
Oct 19, 2024

Conversation

bastimeyer
Copy link
Member

@bastimeyer bastimeyer commented Oct 18, 2024

  • Fix broken bno in pluginmatcher regex and update capture groups names
  • Fix CDN value from API not being used when getting HLS stream URL
  • Add special CDN mapping for "gs_cdn"
  • Update validation schemas, parse JSON in schema, return tuples
  • Update method signatures
  • Set all constants as class attributes
  • Reformat code
  • Update pluginmatcher tests and add plugin options tests

CDN param fix:
#6246 (comment)

bno in pluginmatcher regex was broken since Streamlink 2.0.0 (2020-12-22):
c0baa95#diff-3b4336061632b5600984e648cc9bf2a4eec1f02bcdf259c7648f8275994f8c42R30


channel, channel+bno

$ ./script/test-plugin-urls.py soop -r CHANNEL khm11903 -r 0123456789 277903670
:: https://play.afreecatv.com/khm11903
::  360p, 540p, 720p, 1080p, worst, best
:: https://play.afreecatv.com/khm11903/277903670
::  360p, 540p, 720p, 1080p, worst, best
:: https://play.sooplive.co.kr/khm11903
::  360p, 540p, 720p, 1080p, worst, best
:: https://play.sooplive.co.kr/khm11903/277903670
::  360p, 540p, 720p, 1080p, worst, best

channel with incorrect bno

$ streamlink https://play.sooplive.co.kr/khm11903/00000000
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/khm11903/00000000
Available streams: 360p (worst), 540p, 720p, 1080p (best)

invalid channel

$ streamlink https://play.sooplive.co.kr/doesnotexist
[cli][info] Found matching plugin soop for URL https://play.sooplive.co.kr/doesnotexist
error: No playable streams found on this URL: https://play.sooplive.co.kr/doesnotexist

metadata

$ streamlink -j https://play.sooplive.co.kr/khm11903/277903670 | jq .metadata
{
  "id": "277903670",
  "author": "와꾸대장봉준",
  "category": null,
  "title": "봉준 실제면접 코창서버 면접보러가는길"
}

Even though this code refactor didn't make any changes to the plugin logic, these are the things I didn't test

  • offline channels (I don't use that site, so I don't know anything about anyone there)
  • authentication (valid, invalid, cached) - creating an account requires a phone number (can't be bothered)
  • password-protected streams

@minibox24 Since you were the last person who updated the plugin, could you please have a quick look when you have the time and check that I didn't break anything by accident? Thanks!

@bastimeyer bastimeyer added the plugin issue A Plugin does not work correctly label Oct 18, 2024
@minibox24
Copy link
Contributor

minibox24 commented Oct 19, 2024

#6246 (comment)
#3738

Regardless of IP, the API unconditionally returns the CDN as gs_cdn,
On Korean IPs, the stream is not opened due to 400.

The constant CDN before this refactoring, gcp_cdn, does open on non-Korean IPs.
I'll try to fix the structure when I have some time.

+) Other than that, offline, authentication, and passwords all work.

@bastimeyer
Copy link
Member Author

On Korean IPs, the stream is not opened due to 400.

These are the CDNs listed in their JS code:

p = {
	CDN_TYPE: {
		GS: "gs_cdn",
		AWS: "aws_cf",
		AZURE: "azure_cdn",
		GCP: "gcp_cdn"
	},
	STREAM_MANAGER: {
		CDN_TYPE: {
			GS_CDN_PC_WEB: "gs_cdn_pc_web",
			GS_CDN_PC_APP: "gs_cdn_pc_app",
			GS_CDN_MOBILE_WEB: "gs_cdn_mobile_web",
			KT_CDN: "kt_cdn",
			GS_CDN_CHROMECAST: "gs_cdn_chromecast",
			GS_CDN_PREVIEW: "gs_cdn_preview"
		},
		get cdnType() {
			return n.A.isChromecast()
				? p.STREAM_MANAGER.CDN_TYPE.GS_CDN_CHROMECAST
				: -1 !== r.A.szCdnType.indexOf(p.CDN_TYPE.GS)
					? n.A.isMobile()
						? p.STREAM_MANAGER.CDN_TYPE.GS_CDN_MOBILE_WEB
						: p.STREAM_MANAGER.CDN_TYPE.GS_CDN_PC_WEB
					: r.A.szCdnType
		},
	},
}

The STREAM_MANAGER.cdnType getter is used for the return_type parameter when getting the HLS playlist URL. r.A.szCdnType is the result of the API response (e object): e.CDN && (this.szCdnType = e.CDN).

This means that there's a special mapping for the p.CDN_TYPE.GS type, for mobile / PC.

@bastimeyer bastimeyer force-pushed the plugins/soop/refactor branch from bff6e63 to a293ff6 Compare October 19, 2024 12:20
- Fix broken bno in pluginmatcher regex and update capture groups names
- Fix CDN value from API not being used when getting HLS stream URL
- Add special CDN mapping for "gs_cdn"
- Update validation schemas, parse JSON in schema, return tuples
- Update method signatures
- Set all constants as class attributes
- Reformat code
- Update pluginmatcher tests and add plugin options tests
@bastimeyer bastimeyer force-pushed the plugins/soop/refactor branch from a293ff6 to f512dfc Compare October 19, 2024 12:25
@bastimeyer
Copy link
Member Author

Tested with a South-Korean VPN where the CDN API result is gs_cdn. Worked fine. The gcp_cdn CDN value when accessing the API from my German IP address also worked fine.

@minibox24
Copy link
Contributor

image

Everything seems to be working fine 👍

@bastimeyer bastimeyer merged commit 2b52363 into streamlink:master Oct 19, 2024
23 checks passed
@bastimeyer bastimeyer deleted the plugins/soop/refactor branch October 19, 2024 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin issue A Plugin does not work correctly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants