yuliskov / MediaServiceCore

Unofficial Java api for YouTube
40 stars 27 forks source link

Add auto-translate subtitles #6

Closed PeterNjeim closed 1 year ago

PeterNjeim commented 1 year ago

Based on yt-dlp's implementation (yt_dlp/extractor/youtube.py#L3637-L3699)

Resolves https://github.com/yuliskov/SmartTubeNext/issues/244 Resolves https://github.com/yuliskov/SmartTubeNext/issues/1407 Resolves https://github.com/yuliskov/SmartTubeNext/issues/1741 Resolves https://github.com/yuliskov/SmartTubeNext/issues/1745

PeterNjeim commented 1 year ago

Currently the subtitles "overlap" and so it doesn't show all the possibilites, this is on purpose since I plan on making a separate menu just like the desktop YouTube version

PeterNjeim commented 1 year ago

Basically, what I did was make something called PageInfo, which is similar to VideoInfo, and I also made something called RegExpAndJsonPath, which is similar to both RegExp and JsonPath (because I download an HTML page, then use RegExp to extract the JSON, then use JsonPath to parse it). Then I added the boilerplate in the service folder and that's pretty much it.

yuliskov commented 1 year ago

Thanks, friend. I'll check the pull request.

PeterNjeim commented 1 year ago

It's in draft mode right now, since I plan on fixing up the remaining tasks, so no need to review it currently unless you want to change the direction I'm going with it right now

yuliskov commented 1 year ago

@PeterNjeim agreed. The code should be checked first. Maybe I'll do the rest.

PeterNjeim commented 1 year ago

I'm having lots of trouble with this. As far as I can tell, in PlayerUIManager, I can't dynamically change the settingsPresenter after showDialog is called, meaning there's no way to make a category for auto-translated subtitles which dynamically updates its options to match the selected subtitle (if user selects Spanish subtitles, show subtitles translated from Spanish). If there are multiple human-translated languages, the number of auto-translated languages gets very large, on some popular videos it's over 1500, so showing all the subtitles is not an option. Is there any way you could make it so that there could be a dynamic radio category for the settingsPresenter? If not, as a workaround users would need to click back twice to go to the player UI, and then click on the subtitles button a second time to enable the auto-translate option.

yuliskov commented 1 year ago

Seems that I've found an easier way for this. Thanks for your efforts.