From 02b956940a626daaed1ba2af70954ac152324237 Mon Sep 17 00:00:00 2001 From: CranberrySoup <142951702+CranberrySoup@users.noreply.github.com> Date: Thu, 4 Jul 2024 18:07:01 +0000 Subject: [PATCH] Port large parts of the API to crossplatform (#1163) --- app/build.gradle.kts | 2 + .../lagradost/cloudstream3/AcraApplication.kt | 4 +- .../lagradost/cloudstream3/CommonActivity.kt | 2 +- .../lagradost/cloudstream3/MainActivity.kt | 24 +- .../cloudstream3/network/CloudflareKiller.kt | 1 + .../cloudstream3/plugins/PluginManager.kt | 2 +- .../services/BackupWorkManager.kt | 2 +- .../services/SubscriptionWorkManager.kt | 4 +- .../syncproviders/AccountManager.kt | 13 +- .../syncproviders/{SyncAPI.kt => SyncApi.kt} | 10 - .../syncproviders/providers/AniListApi.kt | 2 +- .../syncproviders/providers/MALApi.kt | 2 +- .../providers/OpenSubtitlesApi.kt | 1 + .../syncproviders/providers/SimklApi.kt | 55 +--- .../cloudstream3/ui/ControllerActivity.kt | 2 +- .../cloudstream3/ui/WebviewFragment.kt | 2 +- .../cloudstream3/ui/account/AccountHelper.kt | 2 +- .../ui/download/DownloadAdapter.kt | 3 +- .../ui/download/DownloadButtonSetup.kt | 6 +- .../ui/download/DownloadFragment.kt | 3 +- .../cloudstream3/ui/home/HomeFragment.kt | 14 +- .../ui/home/HomeParentItemAdapter.kt | 2 +- .../ui/home/HomeParentItemAdapterPreview.kt | 2 +- .../cloudstream3/ui/home/HomeViewModel.kt | 10 +- .../ui/library/LibraryFragment.kt | 6 +- .../cloudstream3/ui/library/PageAdapter.kt | 4 +- .../ui/player/AbstractPlayerFragment.kt | 6 +- .../cloudstream3/ui/player/CS3IPlayer.kt | 3 +- .../ui/player/DownloadFileGenerator.kt | 1 - .../ui/player/DownloadedPlayerActivity.kt | 4 + .../ui/player/ExtractorLinkGenerator.kt | 1 - .../ui/player/FullScreenPlayer.kt | 2 +- .../cloudstream3/ui/player/GeneratorPlayer.kt | 1 + .../cloudstream3/ui/player/IGenerator.kt | 1 - .../cloudstream3/ui/player/IPlayer.kt | 1 - .../cloudstream3/ui/player/LinkGenerator.kt | 20 +- .../ui/player/OfflinePlaybackHelper.kt | 2 +- .../ui/player/PlayerGeneratorViewModel.kt | 1 - .../ui/player/PreviewGenerator.kt | 3 - .../ui/player/RepoLinkGenerator.kt | 1 - .../player/source_priority/PriorityAdapter.kt | 4 +- .../player/source_priority/ProfilesAdapter.kt | 4 +- .../ui/quicksearch/QuickSearchFragment.kt | 7 +- .../cloudstream3/ui/result/ActorAdaptor.kt | 2 +- .../cloudstream3/ui/result/EpisodeAdapter.kt | 2 +- .../cloudstream3/ui/result/ResultFragment.kt | 2 +- .../ui/result/ResultFragmentPhone.kt | 10 +- .../ui/result/ResultFragmentTv.kt | 9 +- .../ui/result/ResultViewModel2.kt | 108 +++++-- .../cloudstream3/ui/result/UiText.kt | 2 +- .../cloudstream3/ui/search/SearchFragment.kt | 14 +- .../cloudstream3/ui/search/SearchHelper.kt | 2 +- .../ui/search/SearchResultBuilder.kt | 2 +- .../ui/settings/SettingsAccount.kt | 6 +- .../ui/settings/SettingsProviders.kt | 6 +- .../settings/extensions/ExtensionsFragment.kt | 4 +- .../ui/settings/extensions/PluginAdapter.kt | 2 +- .../ui/settings/extensions/PluginsFragment.kt | 2 +- .../ui/settings/testing/TestResultAdapter.kt | 4 +- .../ui/settings/testing/TestView.kt | 2 +- .../ui/setup/SetupFragmentProviderLanguage.kt | 2 +- .../utils/{AppUtils.kt => AppContextUtils.kt} | 187 +++++++++-- .../cloudstream3/utils/DataStoreHelper.kt | 2 +- .../cloudstream3/utils/InAppUpdater.kt | 2 +- .../utils/PackageInstallerService.kt | 2 +- .../utils/VideoDownloadManager.kt | 11 +- library/build.gradle.kts | 9 + .../lagradost/api/ContextHelper.android.kt | 20 ++ .../network/WebViewResolver.android.kt | 43 +-- .../kotlin/com/lagradost/api/ContextHelper.kt | 16 + .../com/lagradost/cloudstream3/MainAPI.kt | 290 ++++-------------- .../cloudstream3/extractors/AStreamHub.kt | 2 +- .../cloudstream3/extractors/Acefile.kt | 0 .../cloudstream3/extractors/AsianLoad.kt | 0 .../cloudstream3/extractors/Blogger.kt | 0 .../cloudstream3/extractors/BullStream.kt | 0 .../cloudstream3/extractors/ByteShare.kt | 0 .../lagradost/cloudstream3/extractors/Cda.kt | 0 .../cloudstream3/extractors/Chillx.kt | 0 .../extractors/ContentXExtractor.kt | 2 +- .../cloudstream3/extractors/Dailymotion.kt | 0 .../cloudstream3/extractors/DoodExtractor.kt | 0 .../cloudstream3/extractors/EPlay.kt | 0 .../cloudstream3/extractors/Embedgram.kt | 0 .../extractors/EmturbovidExtractor.kt | 0 .../cloudstream3/extractors/Evolaod.kt | 0 .../cloudstream3/extractors/Fastream.kt | 0 .../cloudstream3/extractors/Filesim.kt | 0 .../cloudstream3/extractors/GMPlayer.kt | 0 .../cloudstream3/extractors/Gdriveplayer.kt | 0 .../cloudstream3/extractors/GenericM3U8.kt | 0 .../cloudstream3/extractors/Gofile.kt | 0 .../extractors/GoodstreamExtractor.kt | 0 .../cloudstream3/extractors/GuardareStream.kt | 0 .../extractors/HDMomPlayerExtractor.kt | 2 +- .../extractors/HDPlayerSystemExtractor.kt | 2 +- .../extractors/HDStreamAbleExtractor.kt | 0 .../extractors/HotlingerExtractor.kt | 0 .../cloudstream3/extractors/Hxfile.kt | 0 .../cloudstream3/extractors/JWPlayer.kt | 0 .../cloudstream3/extractors/Jawcloud.kt | 0 .../cloudstream3/extractors/Jeniusplay.kt | 0 .../cloudstream3/extractors/Krakenfiles.kt | 0 .../cloudstream3/extractors/Linkbox.kt | 0 .../cloudstream3/extractors/M3u8Manifest.kt | 0 .../extractors/MailRuExtractor.kt | 2 +- .../cloudstream3/extractors/Maxstream.kt | 0 .../cloudstream3/extractors/Mediafire.kt | 0 .../cloudstream3/extractors/Minoplres.kt | 0 .../cloudstream3/extractors/MixDrop.kt | 0 .../cloudstream3/extractors/Moviehab.kt | 0 .../cloudstream3/extractors/Mp4Upload.kt | 0 .../cloudstream3/extractors/MultiQuality.kt | 0 .../cloudstream3/extractors/Mvidoo.kt | 0 .../extractors/OdnoklassnikiExtractor.kt | 2 +- .../cloudstream3/extractors/OkRuExtractor.kt | 0 .../cloudstream3/extractors/Okrulink.kt | 0 .../extractors/PeaceMakerstExtractor.kt | 2 +- .../cloudstream3/extractors/Pelisplus.kt | 0 .../extractors/PixelDrainExtractor.kt | 0 .../cloudstream3/extractors/PlayLtXyz.kt | 2 +- .../cloudstream3/extractors/PlayerVoxzer.kt | 0 .../cloudstream3/extractors/Rabbitstream.kt | 0 .../extractors/RapidVidExtractor.kt | 2 +- .../cloudstream3/extractors/SBPlay.kt | 0 .../cloudstream3/extractors/Sendvid.kt | 0 .../extractors/SibNetExtractor.kt | 2 +- .../cloudstream3/extractors/Solidfiles.kt | 0 .../cloudstream3/extractors/StreamSB.kt | 0 .../cloudstream3/extractors/StreamTape.kt | 0 .../extractors/StreamWishExtractor.kt | 0 .../cloudstream3/extractors/Streamhub.kt | 0 .../cloudstream3/extractors/Streamlare.kt | 0 .../cloudstream3/extractors/StreamoUpload.kt | 0 .../cloudstream3/extractors/Streamplay.kt | 0 .../cloudstream3/extractors/Supervideo.kt | 0 .../cloudstream3/extractors/TRsTXExtractor.kt | 2 +- .../cloudstream3/extractors/Tantifilm.kt | 0 .../extractors/TauVideoExtractor.kt | 2 +- .../cloudstream3/extractors/Tomatomatela.kt | 0 .../extractors/UpstreamExtractor.kt | 0 .../cloudstream3/extractors/Uqload.kt | 0 .../cloudstream3/extractors/Userload.kt | 0 .../cloudstream3/extractors/Userscloud.kt | 0 .../cloudstream3/extractors/Uservideo.kt | 0 .../cloudstream3/extractors/Vicloud.kt | 0 .../extractors/VidMoxyExtractor.kt | 2 +- .../extractors/VidSrcExtractor.kt | 0 .../cloudstream3/extractors/VidSrcTo.kt | 142 ++++----- .../extractors/VideoSeyredExtractor.kt | 2 +- .../cloudstream3/extractors/VideoVard.kt | 0 .../cloudstream3/extractors/Vidguard.kt | 4 +- .../extractors/VidhideExtractor.kt | 0 .../cloudstream3/extractors/Vidmoly.kt | 0 .../lagradost/cloudstream3/extractors/Vido.kt | 0 .../cloudstream3/extractors/Vidplay.kt | 0 .../cloudstream3/extractors/Vidstream.kt | 0 .../lagradost/cloudstream3/extractors/Voe.kt | 6 +- .../lagradost/cloudstream3/extractors/Vtbe.kt | 0 .../cloudstream3/extractors/WatchSB.kt | 0 .../cloudstream3/extractors/WcoStream.kt | 0 .../cloudstream3/extractors/Wibufile.kt | 0 .../cloudstream3/extractors/XStreamCdn.kt | 0 .../cloudstream3/extractors/YourUpload.kt | 0 .../extractors/YoutubeExtractor.kt | 0 .../cloudstream3/extractors/Zorofile.kt | 0 .../cloudstream3/extractors/Zplayer.kt | 0 .../extractors/helper/AesHelper.kt | 0 .../extractors/helper/AsianEmbedHelper.kt | 2 +- .../extractors/helper/GogoHelper.kt | 0 .../extractors/helper/NineAnimeHelper.kt | 0 .../extractors/helper/VstreamhubHelper.kt | 0 .../extractors/helper/WcoHelper.kt | 10 +- .../cloudstream3/network/WebViewResolver.kt | 28 ++ .../cloudstream3/syncproviders/SyncAPI.kt | 10 + .../lagradost/cloudstream3/utils/AppUtils.kt | 24 ++ .../cloudstream3/utils/ExtractorApi.kt | 28 +- .../cloudstream3/utils/M3u8Helper.kt | 0 .../cloudstream3/utils/UnshortenUrl.kt | 6 +- .../com/lagradost/api/ContextHelper.jvm.kt | 10 + .../network/WebViewResolver.jvm.kt | 35 +++ 181 files changed, 730 insertions(+), 608 deletions(-) rename app/src/main/java/com/lagradost/cloudstream3/syncproviders/{SyncAPI.kt => SyncApi.kt} (97%) rename app/src/main/java/com/lagradost/cloudstream3/utils/{AppUtils.kt => AppContextUtils.kt} (82%) create mode 100644 library/src/androidMain/kotlin/com/lagradost/api/ContextHelper.android.kt rename app/src/main/java/com/lagradost/cloudstream3/network/WebViewResolver.kt => library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt (90%) create mode 100644 library/src/commonMain/kotlin/com/lagradost/api/ContextHelper.kt rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/MainAPI.kt (86%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/AStreamHub.kt (97%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Acefile.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/AsianLoad.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Blogger.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/BullStream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/ByteShare.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Cda.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Chillx.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Dailymotion.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/DoodExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/EPlay.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Embedgram.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/EmturbovidExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Evolaod.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Fastream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Filesim.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/GMPlayer.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/GenericM3U8.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Gofile.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/GoodstreamExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/GuardareStream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/HDStreamAbleExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/HotlingerExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Hxfile.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/JWPlayer.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Jawcloud.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Jeniusplay.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Krakenfiles.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Linkbox.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/M3u8Manifest.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Maxstream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Mediafire.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Minoplres.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/MixDrop.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Moviehab.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Mp4Upload.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/MultiQuality.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Mvidoo.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/OkRuExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Okrulink.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt (99%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Pelisplus.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/PixelDrainExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt (99%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Rabbitstream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/SBPlay.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Sendvid.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt (97%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Solidfiles.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/StreamSB.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/StreamTape.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Streamhub.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Streamlare.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/StreamoUpload.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Streamplay.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Supervideo.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Tantifilm.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Tomatomatela.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/UpstreamExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Uqload.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Userload.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Userscloud.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Uservideo.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vicloud.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VidSrcExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VidSrcTo.kt (88%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt (98%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VideoVard.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vidguard.kt (97%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/VidhideExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vidmoly.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vido.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vidplay.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vidstream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Voe.kt (93%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Vtbe.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/WatchSB.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/WcoStream.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Wibufile.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/XStreamCdn.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/YourUpload.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/YoutubeExtractor.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Zorofile.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/Zplayer.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/AesHelper.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt (97%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/GogoHelper.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/VstreamhubHelper.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt (76%) create mode 100644 library/src/commonMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.kt create mode 100644 library/src/commonMain/kotlin/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt create mode 100644 library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/utils/ExtractorApi.kt (97%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/utils/M3u8Helper.kt (100%) rename {app/src/main/java => library/src/commonMain/kotlin}/com/lagradost/cloudstream3/utils/UnshortenUrl.kt (96%) create mode 100644 library/src/jvmMain/kotlin/com/lagradost/api/ContextHelper.jvm.kt create mode 100644 library/src/jvmMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.jvm.kt diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 9c75a90d..ebefa0ea 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -263,6 +263,8 @@ tasks.register("copyJar") { // Merge the app classes and the library classes into classes.jar tasks.register("makeJar") { + // Duplicates cause hard to catch errors, better to fail at compile time. + duplicatesStrategy = DuplicatesStrategy.FAIL dependsOn(tasks.getByName("copyJar")) from( zipTree("build/app-classes/classes.jar"), diff --git a/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt b/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt index 1680d698..598ff540 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/AcraApplication.kt @@ -8,13 +8,14 @@ import android.content.Intent import android.widget.Toast import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentActivity +import com.lagradost.api.setContext import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.mvvm.suspendSafeApiCall import com.lagradost.cloudstream3.plugins.PluginManager import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.openBrowser +import com.lagradost.cloudstream3.utils.AppContextUtils.openBrowser import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread import com.lagradost.cloudstream3.utils.DataStore.getKey import com.lagradost.cloudstream3.utils.DataStore.getKeys @@ -151,6 +152,7 @@ class AcraApplication : Application() { get() = _context?.get() private set(value) { _context = WeakReference(value) + setContext(WeakReference(value)) } fun getKeyClass(path: String, valueType: Class): T? { diff --git a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt index 82e985db..ba303fef 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/CommonActivity.kt @@ -36,7 +36,7 @@ import com.lagradost.cloudstream3.ui.player.PlayerEventType import com.lagradost.cloudstream3.ui.result.ResultFragment import com.lagradost.cloudstream3.ui.result.UiText import com.lagradost.cloudstream3.ui.settings.Globals.updateTv -import com.lagradost.cloudstream3.utils.AppUtils.isRtl +import com.lagradost.cloudstream3.utils.AppContextUtils.isRtl import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.Event import com.lagradost.cloudstream3.utils.UIHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt index 21567e4d..a47e7685 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/MainActivity.kt @@ -56,9 +56,7 @@ import com.google.common.collect.Comparators.min import com.jaredrummler.android.colorpicker.ColorPickerDialogListener import com.lagradost.cloudstream3.APIHolder.allProviders import com.lagradost.cloudstream3.APIHolder.apis -import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.APIHolder.initAll -import com.lagradost.cloudstream3.APIHolder.updateHasTrailers import com.lagradost.cloudstream3.AcraApplication.Companion.getKey import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.AcraApplication.Companion.setKey @@ -121,16 +119,18 @@ import com.lagradost.cloudstream3.ui.settings.SettingsGeneral import com.lagradost.cloudstream3.ui.setup.HAS_DONE_SETUP_KEY import com.lagradost.cloudstream3.ui.setup.SetupFragmentExtensions import com.lagradost.cloudstream3.utils.ApkInstaller -import com.lagradost.cloudstream3.utils.AppUtils.html -import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable -import com.lagradost.cloudstream3.utils.AppUtils.isLtr -import com.lagradost.cloudstream3.utils.AppUtils.isNetworkAvailable -import com.lagradost.cloudstream3.utils.AppUtils.isRtl -import com.lagradost.cloudstream3.utils.AppUtils.loadCache -import com.lagradost.cloudstream3.utils.AppUtils.loadRepository -import com.lagradost.cloudstream3.utils.AppUtils.loadResult -import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiDubstatusSettings +import com.lagradost.cloudstream3.utils.AppContextUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.isCastApiAvailable +import com.lagradost.cloudstream3.utils.AppContextUtils.isLtr +import com.lagradost.cloudstream3.utils.AppContextUtils.isNetworkAvailable +import com.lagradost.cloudstream3.utils.AppContextUtils.isRtl +import com.lagradost.cloudstream3.utils.AppContextUtils.loadCache +import com.lagradost.cloudstream3.utils.AppContextUtils.loadRepository +import com.lagradost.cloudstream3.utils.AppContextUtils.loadResult +import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.updateHasTrailers import com.lagradost.cloudstream3.utils.BackupUtils.backup import com.lagradost.cloudstream3.utils.BackupUtils.setUpBackup import com.lagradost.cloudstream3.utils.BiometricAuthenticator.BiometricCallback diff --git a/app/src/main/java/com/lagradost/cloudstream3/network/CloudflareKiller.kt b/app/src/main/java/com/lagradost/cloudstream3/network/CloudflareKiller.kt index c8c385cf..ce2fb3a2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/network/CloudflareKiller.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/network/CloudflareKiller.kt @@ -1,5 +1,6 @@ package com.lagradost.cloudstream3.network +import android.util.Base64 import android.util.Log import android.webkit.CookieManager import androidx.annotation.AnyThread diff --git a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt index a5631500..6b2b75f2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/plugins/PluginManager.kt @@ -14,7 +14,6 @@ import androidx.fragment.app.FragmentActivity import com.fasterxml.jackson.annotation.JsonProperty import com.google.gson.Gson import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings import com.lagradost.cloudstream3.APIHolder.removePluginMapping import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity import com.lagradost.cloudstream3.AcraApplication.Companion.getKey @@ -33,6 +32,7 @@ import com.lagradost.cloudstream3.ui.result.UiText import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.ui.settings.extensions.REPOSITORIES_KEY import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute diff --git a/app/src/main/java/com/lagradost/cloudstream3/services/BackupWorkManager.kt b/app/src/main/java/com/lagradost/cloudstream3/services/BackupWorkManager.kt index 6ed7a447..4ef841f5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/services/BackupWorkManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/services/BackupWorkManager.kt @@ -10,7 +10,7 @@ import androidx.work.PeriodicWorkRequest import androidx.work.WorkManager import androidx.work.WorkerParameters import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.utils.AppUtils.createNotificationChannel +import com.lagradost.cloudstream3.utils.AppContextUtils.createNotificationChannel import com.lagradost.cloudstream3.utils.BackupUtils import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import java.util.concurrent.TimeUnit diff --git a/app/src/main/java/com/lagradost/cloudstream3/services/SubscriptionWorkManager.kt b/app/src/main/java/com/lagradost/cloudstream3/services/SubscriptionWorkManager.kt index e2bcd6e1..00c74dff 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/services/SubscriptionWorkManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/services/SubscriptionWorkManager.kt @@ -10,13 +10,13 @@ import androidx.core.app.NotificationCompat import androidx.core.net.toUri import androidx.work.* import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.plugins.PluginManager import com.lagradost.cloudstream3.ui.result.txt -import com.lagradost.cloudstream3.utils.AppUtils.createNotificationChannel +import com.lagradost.cloudstream3.utils.AppContextUtils.createNotificationChannel +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiDubstatusSettings import com.lagradost.cloudstream3.utils.Coroutines.ioWork import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.getAllSubscriptions diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt index a14f8438..e86d73aa 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/AccountManager.kt @@ -3,15 +3,22 @@ package com.lagradost.cloudstream3.syncproviders import com.lagradost.cloudstream3.AcraApplication.Companion.getKey import com.lagradost.cloudstream3.AcraApplication.Companion.removeKeys import com.lagradost.cloudstream3.AcraApplication.Companion.setKey +import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.syncproviders.providers.* import java.util.concurrent.TimeUnit abstract class AccountManager(private val defIndex: Int) : AuthAPI { companion object { - val malApi = MALApi(0) - val aniListApi = AniListApi(0) + val malApi = MALApi(0).also { api -> + LoadResponse.Companion.malIdPrefix = api.idPrefix + } + val aniListApi = AniListApi(0).also { api -> + LoadResponse.Companion.aniListIdPrefix = api.idPrefix + } + val simklApi = SimklApi(0).also { api -> + LoadResponse.Companion.simklIdPrefix = api.idPrefix + } val openSubtitlesApi = OpenSubtitlesApi(0) - val simklApi = SimklApi(0) val addic7ed = Addic7ed() val subDlApi = SubDlApi(0) val localListApi = LocalList() diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncApi.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt rename to app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncApi.kt index 045fdc94..878e0cb3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/SyncApi.kt @@ -2,20 +2,10 @@ package com.lagradost.cloudstream3.syncproviders import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.ui.SyncWatchType -import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.library.ListSorting import com.lagradost.cloudstream3.ui.result.UiText import me.xdrop.fuzzywuzzy.FuzzySearch -enum class SyncIdName { - Anilist, - MyAnimeList, - Trakt, - Imdb, - Simkl, - LocalList, -} - interface SyncAPI : OAuth2API { /** * Set this to true if the user updates something on the list like watch status or score diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt index 0551fe6c..8a82cf94 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/AniListApi.kt @@ -17,7 +17,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType import com.lagradost.cloudstream3.ui.library.ListSorting import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.utils.AppUtils.parseJson -import com.lagradost.cloudstream3.utils.AppUtils.splitQuery +import com.lagradost.cloudstream3.utils.AppContextUtils.splitQuery import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.Coroutines.ioSafe diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt index 4249f949..24ef7136 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/MALApi.kt @@ -20,7 +20,7 @@ import com.lagradost.cloudstream3.ui.SyncWatchType import com.lagradost.cloudstream3.ui.library.ListSorting import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.utils.AppUtils.parseJson -import com.lagradost.cloudstream3.utils.AppUtils.splitQuery +import com.lagradost.cloudstream3.utils.AppContextUtils.splitQuery import com.lagradost.cloudstream3.utils.DataStore.toKotlinObject import java.net.URL import java.security.SecureRandom diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt index 7d0514d1..6412ff1b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt @@ -15,6 +15,7 @@ import com.lagradost.cloudstream3.subtitles.AbstractSubtitleEntities import com.lagradost.cloudstream3.syncproviders.AuthAPI import com.lagradost.cloudstream3.syncproviders.InAppAuthAPI import com.lagradost.cloudstream3.syncproviders.InAppAuthAPIManager +import com.lagradost.cloudstream3.utils.AppContextUtils import com.lagradost.cloudstream3.utils.AppUtils import okhttp3.Interceptor import okhttp3.Response diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/SimklApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/SimklApi.kt index 4385fa5e..27975d19 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/SimklApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/SimklApi.kt @@ -12,7 +12,9 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.openBrowser import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.AcraApplication.Companion.setKey import com.lagradost.cloudstream3.BuildConfig +import com.lagradost.cloudstream3.LoadResponse.Companion.readIdFromString import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.SimklSyncServices import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.mapper @@ -29,7 +31,6 @@ import com.lagradost.cloudstream3.ui.SyncWatchType import com.lagradost.cloudstream3.ui.library.ListSorting import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.utils.AppUtils.toJson -import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import okhttp3.Interceptor import okhttp3.Response import java.math.BigInteger @@ -184,32 +185,6 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI { } } - /** - * Set of sync services simkl is compatible with. - * Add more as required: https://simkl.docs.apiary.io/#reference/search/id-lookup/get-items-by-id - */ - enum class SyncServices(val originalName: String) { - Simkl("simkl"), - Imdb("imdb"), - Tmdb("tmdb"), - AniList("anilist"), - Mal("mal"), - } - - /** - * The ID string is a way to keep a collection of services in one single ID using a map - * This adds a database service (like imdb) to the string and returns the new string. - */ - fun addIdToString(idString: String?, database: SyncServices, id: String?): String? { - if (id == null) return idString - return (readIdFromString(idString) + mapOf(database to id)).toJson() - } - - /** Read the id string to get all other ids */ - fun readIdFromString(idString: String?): Map { - return tryParseJson(idString) ?: return emptyMap() - } - fun getPosterUrl(poster: String): String { return "https://wsrv.nl/?url=https://simkl.in/posters/${poster}_m.webp" } @@ -361,13 +336,13 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI { @JsonProperty("anilist") val anilist: String? = null, ) { companion object { - fun fromMap(map: Map): Ids { + fun fromMap(map: Map): Ids { return Ids( - simkl = map[SyncServices.Simkl]?.toIntOrNull(), - imdb = map[SyncServices.Imdb], - tmdb = map[SyncServices.Tmdb], - mal = map[SyncServices.Mal], - anilist = map[SyncServices.AniList] + simkl = map[SimklSyncServices.Simkl]?.toIntOrNull(), + imdb = map[SimklSyncServices.Imdb], + tmdb = map[SimklSyncServices.Tmdb], + mal = map[SimklSyncServices.Mal], + anilist = map[SimklSyncServices.AniList] ) } } @@ -749,13 +724,13 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI { @JsonProperty("anilist") val anilist: String?, @JsonProperty("traktslug") val traktslug: String? ) { - fun matchesId(database: SyncServices, id: String): Boolean { + fun matchesId(database: SimklSyncServices, id: String): Boolean { return when (database) { - SyncServices.Simkl -> this.simkl == id.toIntOrNull() - SyncServices.AniList -> this.anilist == id - SyncServices.Mal -> this.mal == id - SyncServices.Tmdb -> this.tmdb == id - SyncServices.Imdb -> this.imdb == id + SimklSyncServices.Simkl -> this.simkl == id.toIntOrNull() + SimklSyncServices.AniList -> this.anilist == id + SimklSyncServices.Mal -> this.mal == id + SimklSyncServices.Tmdb -> this.tmdb == id + SimklSyncServices.Imdb -> this.imdb == id } } } @@ -916,7 +891,7 @@ class SimklApi(index: Int) : AccountManager(index), SyncAPI { /** See https://simkl.docs.apiary.io/#reference/search/id-lookup/get-items-by-id */ - suspend fun searchByIds(serviceMap: Map): Array? { + suspend fun searchByIds(serviceMap: Map): Array? { if (serviceMap.isEmpty()) return emptyArray() return app.get( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/ControllerActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/ControllerActivity.kt index 688363e9..6bafa975 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/ControllerActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/ControllerActivity.kt @@ -23,13 +23,13 @@ import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.Resource import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.safeApiCall -import com.lagradost.cloudstream3.sortSubs import com.lagradost.cloudstream3.sortUrls import com.lagradost.cloudstream3.ui.player.LoadType import com.lagradost.cloudstream3.ui.player.RepoLinkGenerator import com.lagradost.cloudstream3.ui.player.SubtitleData import com.lagradost.cloudstream3.ui.result.ResultEpisode import com.lagradost.cloudstream3.ui.subtitles.ChromecastSubtitlesFragment +import com.lagradost.cloudstream3.utils.AppContextUtils.sortSubs import com.lagradost.cloudstream3.utils.AppUtils.toJson import com.lagradost.cloudstream3.utils.CastHelper.awaitLinks import com.lagradost.cloudstream3.utils.CastHelper.getMediaInfo diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt index 9ed58e2c..15e66b38 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/WebviewFragment.kt @@ -15,7 +15,7 @@ import com.lagradost.cloudstream3.MainActivity import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.cloudstream3.databinding.FragmentWebviewBinding import com.lagradost.cloudstream3.network.WebViewResolver -import com.lagradost.cloudstream3.utils.AppUtils.loadRepository +import com.lagradost.cloudstream3.utils.AppContextUtils.loadRepository class WebviewFragment : Fragment() { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountHelper.kt index 1db49e27..d2aca862 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/account/AccountHelper.kt @@ -27,7 +27,7 @@ import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.observe import com.lagradost.cloudstream3.ui.result.setImage import com.lagradost.cloudstream3.ui.result.setLinearListLayout -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.getDefaultAccount import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt index 1132416a..b4a16a66 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadAdapter.kt @@ -13,8 +13,9 @@ import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.DownloadChildEpisodeBinding import com.lagradost.cloudstream3.databinding.DownloadHeaderEpisodeBinding import com.lagradost.cloudstream3.mvvm.logError +import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull +import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.ui.download.button.DownloadStatusTell -import com.lagradost.cloudstream3.utils.AppUtils.getNameFull import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos import com.lagradost.cloudstream3.utils.UIHelper.setImage diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt index 880d5f6c..c8c40e29 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadButtonSetup.kt @@ -9,11 +9,11 @@ import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.ui.player.DownloadFileGenerator +import com.lagradost.cloudstream3.ui.player.ExtractorUri import com.lagradost.cloudstream3.ui.player.GeneratorPlayer -import com.lagradost.cloudstream3.utils.AppUtils.getNameFull -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE -import com.lagradost.cloudstream3.utils.ExtractorUri import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.cloudstream3.utils.VideoDownloadHelper import com.lagradost.cloudstream3.utils.VideoDownloadManager diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt index d5427cd3..82c5ffb8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/download/DownloadFragment.kt @@ -39,7 +39,8 @@ import com.lagradost.cloudstream3.ui.result.FOCUS_SELF import com.lagradost.cloudstream3.ui.result.setLinearListLayout import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.loadResult +import com.lagradost.cloudstream3.utils.AppContextUtils.loadResult +import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE import com.lagradost.cloudstream3.utils.DataStore import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index 12185cbf..82a92d80 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -25,8 +25,6 @@ import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.chip.Chip import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.apis -import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.databinding.FragmentHomeBinding import com.lagradost.cloudstream3.databinding.HomeEpisodesExpandedBinding @@ -46,11 +44,13 @@ import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.isRecyclerScrollable -import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult -import com.lagradost.cloudstream3.utils.AppUtils.ownHide -import com.lagradost.cloudstream3.utils.AppUtils.ownShow -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings +import com.lagradost.cloudstream3.utils.AppContextUtils.isRecyclerScrollable +import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult +import com.lagradost.cloudstream3.utils.AppContextUtils.ownHide +import com.lagradost.cloudstream3.utils.AppContextUtils.ownShow +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.Event diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt index 4b0360d7..916cb9ae 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapter.kt @@ -22,7 +22,7 @@ import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.isRecyclerScrollable +import com.lagradost.cloudstream3.utils.AppContextUtils.isRecyclerScrollable class LoadClickCallback( val action: Int = 0, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt index 52ec06db..2e98dd1f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeParentItemAdapterPreview.kt @@ -16,7 +16,6 @@ import androidx.viewbinding.ViewBinding import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.chip.Chip import com.google.android.material.chip.ChipGroup -import com.lagradost.cloudstream3.APIHolder.getId import com.lagradost.cloudstream3.AcraApplication.Companion.getActivity import com.lagradost.cloudstream3.CommonActivity.activity import com.lagradost.cloudstream3.HomePageList @@ -36,6 +35,7 @@ import com.lagradost.cloudstream3.ui.home.HomeFragment.Companion.selectHomepage import com.lagradost.cloudstream3.ui.result.FOCUS_SELF import com.lagradost.cloudstream3.ui.result.ResultViewModel2 import com.lagradost.cloudstream3.ui.result.START_ACTION_RESUME_LATEST +import com.lagradost.cloudstream3.ui.result.getId import com.lagradost.cloudstream3.ui.result.setLinearListLayout import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_LOAD import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_SHOW_METADATA diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt index a2c7583f..9e70d088 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt @@ -6,9 +6,6 @@ import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.lagradost.cloudstream3.APIHolder.apis -import com.lagradost.cloudstream3.APIHolder.filterHomePageListByFilmQuality -import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia -import com.lagradost.cloudstream3.APIHolder.filterSearchResultByFilmQuality import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.AcraApplication.Companion.context import com.lagradost.cloudstream3.AcraApplication.Companion.getKey @@ -36,8 +33,11 @@ import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchHelper import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.addProgramsToContinueWatching -import com.lagradost.cloudstream3.utils.AppUtils.loadResult +import com.lagradost.cloudstream3.utils.AppContextUtils.addProgramsToContinueWatching +import com.lagradost.cloudstream3.utils.AppContextUtils.filterHomePageListByFilmQuality +import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia +import com.lagradost.cloudstream3.utils.AppContextUtils.filterSearchResultByFilmQuality +import com.lagradost.cloudstream3.utils.AppContextUtils.loadResult import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.DOWNLOAD_HEADER_CACHE import com.lagradost.cloudstream3.utils.DataStoreHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt index 90e57ef4..7144de09 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/library/LibraryFragment.kt @@ -53,9 +53,9 @@ import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.loadResult -import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult -import com.lagradost.cloudstream3.utils.AppUtils.reduceDragSensitivity +import com.lagradost.cloudstream3.utils.AppContextUtils.loadResult +import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult +import com.lagradost.cloudstream3.utils.AppContextUtils.reduceDragSensitivity import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/library/PageAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/library/PageAdapter.kt index b8feb656..b2de307f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/library/PageAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/library/PageAdapter.kt @@ -16,7 +16,7 @@ import com.lagradost.cloudstream3.syncproviders.SyncAPI import com.lagradost.cloudstream3.ui.AutofitRecyclerView import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchResultBuilder -import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.AppContextUtils import com.lagradost.cloudstream3.utils.UIHelper.toPx import kotlin.math.roundToInt @@ -26,7 +26,7 @@ class PageAdapter( private val resView: AutofitRecyclerView, val clickCallback: (SearchClickCallback) -> Unit ) : - AppUtils.DiffAdapter(items) { + AppContextUtils.DiffAdapter(items) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return LibraryItemViewHolder( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt index 0865b220..9d838c97 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/AbstractPlayerFragment.kt @@ -44,8 +44,8 @@ import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.unixTimeMs import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment -import com.lagradost.cloudstream3.utils.AppUtils -import com.lagradost.cloudstream3.utils.AppUtils.requestLocalAudioFocus +import com.lagradost.cloudstream3.utils.AppContextUtils +import com.lagradost.cloudstream3.utils.AppContextUtils.requestLocalAudioFocus import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.EpisodeSkip import com.lagradost.cloudstream3.utils.UIHelper @@ -258,7 +258,7 @@ abstract class AbstractPlayerFragment( private fun requestAudioFocus() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - activity?.requestLocalAudioFocus(AppUtils.getFocusRequest()) + activity?.requestLocalAudioFocus(AppContextUtils.getFocusRequest()) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt index 31adbc87..8e322f73 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/CS3IPlayer.kt @@ -57,14 +57,13 @@ import com.lagradost.cloudstream3.mvvm.debugAssert import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle -import com.lagradost.cloudstream3.utils.AppUtils.isUsingMobileData +import com.lagradost.cloudstream3.utils.AppContextUtils.isUsingMobileData import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount import com.lagradost.cloudstream3.utils.DrmExtractorLink import com.lagradost.cloudstream3.utils.EpisodeSkip import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLinkPlayList import com.lagradost.cloudstream3.utils.ExtractorLinkType -import com.lagradost.cloudstream3.utils.ExtractorUri import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTwoLettersToLanguage import java.io.File import java.lang.IllegalArgumentException diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadFileGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadFileGenerator.kt index 5585924e..3b242172 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadFileGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadFileGenerator.kt @@ -4,7 +4,6 @@ import com.lagradost.cloudstream3.AcraApplication.Companion.context import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.ui.player.PlayerSubtitleHelper.Companion.toSubtitleMimeType import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri import com.lagradost.cloudstream3.utils.VideoDownloadManager import kotlin.math.max import kotlin.math.min diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt index 4279b542..92ef279d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/DownloadedPlayerActivity.kt @@ -8,10 +8,14 @@ import androidx.activity.OnBackPressedCallback import androidx.appcompat.app.AppCompatActivity import com.lagradost.cloudstream3.CommonActivity import com.lagradost.cloudstream3.R +import com.lagradost.cloudstream3.utils.UIHelper.navigate +import com.lagradost.safefile.SafeFile import com.lagradost.cloudstream3.mvvm.normalSafeApiCall import com.lagradost.cloudstream3.ui.player.OfflinePlaybackHelper.playLink import com.lagradost.cloudstream3.ui.player.OfflinePlaybackHelper.playUri +const val DTAG = "PlayerActivity" + class DownloadedPlayerActivity : AppCompatActivity() { private val dTAG = "DownloadedPlayerAct" diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt index d8d2d537..8255360c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/ExtractorLinkGenerator.kt @@ -1,7 +1,6 @@ package com.lagradost.cloudstream3.ui.player import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri class ExtractorLinkGenerator( private val links: List, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt index aa25157b..75a861c0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/FullScreenPlayer.kt @@ -45,7 +45,7 @@ import com.lagradost.cloudstream3.ui.settings.Globals import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.isUsingMobileData +import com.lagradost.cloudstream3.utils.AppContextUtils.isUsingMobileData import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt index c77f9404..d827d31e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/GeneratorPlayer.kt @@ -49,6 +49,7 @@ import com.lagradost.cloudstream3.ui.settings.Globals.isLayout import com.lagradost.cloudstream3.ui.subtitles.SUBTITLE_AUTO_SELECT_KEY import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment.Companion.getAutoSelectLanguageISO639_1 import com.lagradost.cloudstream3.utils.* +import com.lagradost.cloudstream3.utils.AppContextUtils.sortSubs import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showDialog diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt index c5de1a1c..1e2cf4f5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IGenerator.kt @@ -2,7 +2,6 @@ package com.lagradost.cloudstream3.ui.player import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLinkType -import com.lagradost.cloudstream3.utils.ExtractorUri enum class LoadType { Unknown, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IPlayer.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IPlayer.kt index 0e54e2cb..4bd5c769 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/IPlayer.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/IPlayer.kt @@ -6,7 +6,6 @@ import android.util.Rational import com.lagradost.cloudstream3.ui.subtitles.SaveCaptionStyle import com.lagradost.cloudstream3.utils.EpisodeSkip import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri enum class PlayerEventType(val value: Int) { //Stop(-1), diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt index 02f44eb9..89e3c8de 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/LinkGenerator.kt @@ -1,13 +1,31 @@ package com.lagradost.cloudstream3.ui.player +import android.net.Uri +import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.amap import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri +import com.lagradost.cloudstream3.ui.player.ExtractorUri import com.lagradost.cloudstream3.utils.INFER_TYPE import com.lagradost.cloudstream3.utils.Qualities import com.lagradost.cloudstream3.utils.loadExtractor import com.lagradost.cloudstream3.utils.unshortenLinkSafe +data class ExtractorUri( + val uri: Uri, + val name: String, + + val basePath: String? = null, + val relativePath: String? = null, + val displayName: String? = null, + + val id: Int? = null, + val parentId: Int? = null, + val episode: Int? = null, + val season: Int? = null, + val headerName: String? = null, + val tvType: TvType? = null, +) + /** * Used to open the player more easily with the LinkGenerator **/ diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/OfflinePlaybackHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/OfflinePlaybackHelper.kt index a52ce160..e6de1266 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/OfflinePlaybackHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/OfflinePlaybackHelper.kt @@ -5,7 +5,7 @@ import android.content.ContentUris import android.net.Uri import androidx.core.content.ContextCompat.getString import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.utils.ExtractorUri +import com.lagradost.cloudstream3.ui.player.ExtractorUri import com.lagradost.cloudstream3.utils.UIHelper.navigate import com.lagradost.safefile.SafeFile diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerGeneratorViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerGeneratorViewModel.kt index ee44567f..1ba5a29f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerGeneratorViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PlayerGeneratorViewModel.kt @@ -15,7 +15,6 @@ import com.lagradost.cloudstream3.ui.result.ResultEpisode import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.EpisodeSkip import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri import kotlinx.coroutines.Job import kotlinx.coroutines.launch diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt index fb600ef1..7c78ce63 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/PreviewGenerator.kt @@ -9,14 +9,11 @@ import android.util.Log import androidx.annotation.WorkerThread import androidx.core.graphics.scale import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.ui.settings.Globals import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.ui.settings.SettingsFragment import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.ExtractorLinkType -import com.lagradost.cloudstream3.utils.ExtractorUri import com.lagradost.cloudstream3.utils.M3u8Helper import com.lagradost.cloudstream3.utils.M3u8Helper2 import kotlinx.coroutines.CoroutineScope diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/RepoLinkGenerator.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/RepoLinkGenerator.kt index 0a194785..90bd1ca7 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/RepoLinkGenerator.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/RepoLinkGenerator.kt @@ -7,7 +7,6 @@ import com.lagradost.cloudstream3.LoadResponse import com.lagradost.cloudstream3.ui.APIRepository import com.lagradost.cloudstream3.ui.result.ResultEpisode import com.lagradost.cloudstream3.utils.ExtractorLink -import com.lagradost.cloudstream3.utils.ExtractorUri import kotlin.math.max import kotlin.math.min diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/PriorityAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/PriorityAdapter.kt index fb60ccce..1e2c9f67 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/PriorityAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/PriorityAdapter.kt @@ -4,7 +4,7 @@ import android.view.LayoutInflater import android.view.ViewGroup import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.databinding.PlayerPrioritizeItemBinding -import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.AppContextUtils data class SourcePriority( val data: T, @@ -13,7 +13,7 @@ data class SourcePriority( ) class PriorityAdapter(override val items: MutableList>) : - AppUtils.DiffAdapter>(items) { + AppContextUtils.DiffAdapter>(items) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return PriorityViewHolder( PlayerPrioritizeItemBinding.inflate(LayoutInflater.from(parent.context),parent,false), diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt index 8153d7a1..b587276f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/player/source_priority/ProfilesAdapter.kt @@ -13,7 +13,7 @@ import androidx.recyclerview.widget.RecyclerView import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.PlayerQualityProfileItemBinding import com.lagradost.cloudstream3.ui.result.UiImage -import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.AppContextUtils import com.lagradost.cloudstream3.utils.UIHelper.setImage class ProfilesAdapter( @@ -21,7 +21,7 @@ class ProfilesAdapter( val usedProfile: Int, val clickCallback: (oldIndex: Int?, newIndex: Int) -> Unit, ) : - AppUtils.DiffAdapter( + AppContextUtils.DiffAdapter( items, comparison = { first: QualityDataHelper.QualityProfile, second: QualityDataHelper.QualityProfile -> first.id == second.id diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt index 85e20d1c..12adc040 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/quicksearch/QuickSearchFragment.kt @@ -17,8 +17,6 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.GridLayoutManager import com.google.android.material.bottomsheet.BottomSheetDialog -import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia -import com.lagradost.cloudstream3.APIHolder.filterSearchResultByFilmQuality import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.CommonActivity.activity import com.lagradost.cloudstream3.HomePageList @@ -34,12 +32,13 @@ import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchClickCallback import com.lagradost.cloudstream3.ui.search.SearchHelper import com.lagradost.cloudstream3.ui.search.SearchViewModel -import com.lagradost.cloudstream3.ui.settings.Globals import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.ownShow +import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia +import com.lagradost.cloudstream3.utils.AppContextUtils.filterSearchResultByFilmQuality +import com.lagradost.cloudstream3.utils.AppContextUtils.ownShow import com.lagradost.cloudstream3.utils.UIHelper import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar import com.lagradost.cloudstream3.utils.UIHelper.getSpanCount diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ActorAdaptor.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ActorAdaptor.kt index 7b743388..61188905 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ActorAdaptor.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ActorAdaptor.kt @@ -138,7 +138,7 @@ class ActorAdaptor( voiceActorImageHolder.isVisible = false voiceActorName.isVisible = false } else { - voiceActorName.text = actor.voiceActor.name + voiceActorName.text = actor.voiceActor?.name voiceActorImageHolder.isVisible = voiceActorImage.setImage(vaImage) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt index 62b1fdd1..0a1b777d 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/EpisodeAdapter.kt @@ -21,7 +21,7 @@ import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.html import com.lagradost.cloudstream3.utils.UIHelper.setImage import com.lagradost.cloudstream3.utils.UIHelper.toPx import com.lagradost.cloudstream3.utils.VideoDownloadHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index 1d3f5a08..c687eaa0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -3,12 +3,12 @@ package com.lagradost.cloudstream3.ui.result import android.os.Bundle import androidx.fragment.app.Fragment import androidx.preference.PreferenceManager -import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.SearchResponse import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.ui.result.EpisodeAdapter.Companion.getPlayerAction +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiDubstatusSettings import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.getVideoWatchState import com.lagradost.cloudstream3.utils.DataStoreHelper.getViewPos diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt index e185e75d..2f297098 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentPhone.kt @@ -29,7 +29,6 @@ import com.google.android.gms.cast.framework.CastContext import com.google.android.gms.cast.framework.CastState import com.google.android.material.bottomsheet.BottomSheetDialog import com.lagradost.cloudstream3.APIHolder -import com.lagradost.cloudstream3.APIHolder.updateHasTrailers import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.LoadResponse @@ -57,10 +56,11 @@ import com.lagradost.cloudstream3.ui.result.ResultFragment.getStoredData import com.lagradost.cloudstream3.ui.result.ResultFragment.updateUIEvent import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchHelper -import com.lagradost.cloudstream3.utils.AppUtils.getNameFull -import com.lagradost.cloudstream3.utils.AppUtils.isCastApiAvailable -import com.lagradost.cloudstream3.utils.AppUtils.loadCache -import com.lagradost.cloudstream3.utils.AppUtils.openBrowser +import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull +import com.lagradost.cloudstream3.utils.AppContextUtils.isCastApiAvailable +import com.lagradost.cloudstream3.utils.AppContextUtils.loadCache +import com.lagradost.cloudstream3.utils.AppContextUtils.openBrowser +import com.lagradost.cloudstream3.utils.AppContextUtils.updateHasTrailers import com.lagradost.cloudstream3.utils.BatteryOptimizationChecker.openBatteryOptimizationSettings import com.lagradost.cloudstream3.utils.ExtractorLink import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt index 13621cda..a0207060 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragmentTv.kt @@ -17,7 +17,6 @@ import androidx.fragment.app.Fragment import androidx.lifecycle.ViewModelProvider import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetDialog -import com.lagradost.cloudstream3.APIHolder.updateHasTrailers import com.lagradost.cloudstream3.CommonActivity import com.lagradost.cloudstream3.DubStatus import com.lagradost.cloudstream3.LoadResponse @@ -40,13 +39,13 @@ import com.lagradost.cloudstream3.ui.result.ResultFragment.updateUIEvent import com.lagradost.cloudstream3.ui.search.SEARCH_ACTION_FOCUSED import com.lagradost.cloudstream3.ui.search.SearchAdapter import com.lagradost.cloudstream3.ui.search.SearchHelper -import com.lagradost.cloudstream3.ui.settings.Globals import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.html -import com.lagradost.cloudstream3.utils.AppUtils.isRtl -import com.lagradost.cloudstream3.utils.AppUtils.loadCache +import com.lagradost.cloudstream3.utils.AppContextUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.isRtl +import com.lagradost.cloudstream3.utils.AppContextUtils.loadCache +import com.lagradost.cloudstream3.utils.AppContextUtils.updateHasTrailers import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialog import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showBottomDialogInstant import com.lagradost.cloudstream3.utils.UIHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt index ac6527de..8e8dfe30 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultViewModel2.kt @@ -18,7 +18,7 @@ import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.APIHolder.apis -import com.lagradost.cloudstream3.APIHolder.getId +import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.APIHolder.unixTime import com.lagradost.cloudstream3.APIHolder.unixTimeMS import com.lagradost.cloudstream3.AcraApplication.Companion.setKey @@ -27,9 +27,9 @@ import com.lagradost.cloudstream3.CommonActivity.getCastSession import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.LoadResponse.Companion.addTrailer import com.lagradost.cloudstream3.LoadResponse.Companion.getAniListId -import com.lagradost.cloudstream3.LoadResponse.Companion.getImdbId import com.lagradost.cloudstream3.LoadResponse.Companion.getMalId import com.lagradost.cloudstream3.LoadResponse.Companion.isMovie +import com.lagradost.cloudstream3.LoadResponse.Companion.readIdFromString import com.lagradost.cloudstream3.MainActivity.Companion.MPV import com.lagradost.cloudstream3.MainActivity.Companion.MPV_COMPONENT import com.lagradost.cloudstream3.MainActivity.Companion.MPV_PACKAGE @@ -56,10 +56,11 @@ import com.lagradost.cloudstream3.ui.player.SubtitleData import com.lagradost.cloudstream3.ui.result.EpisodeAdapter.Companion.getPlayerAction import com.lagradost.cloudstream3.ui.subtitles.SubtitlesFragment import com.lagradost.cloudstream3.utils.* -import com.lagradost.cloudstream3.utils.AppUtils.getNameFull -import com.lagradost.cloudstream3.utils.AppUtils.isAppInstalled -import com.lagradost.cloudstream3.utils.AppUtils.isConnectedToChromecast -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull +import com.lagradost.cloudstream3.utils.AppContextUtils.isAppInstalled +import com.lagradost.cloudstream3.utils.AppContextUtils.isConnectedToChromecast +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.sortSubs import com.lagradost.cloudstream3.utils.CastHelper.startCast import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.ioWork @@ -301,6 +302,23 @@ fun LoadResponse.toResultData(repo: APIRepository): ResultData { ) } +data class ExtractorSubtitleLink( + val name: String, + override val url: String, + override val referer: String, + override val headers: Map = mapOf() +) : IDownloadableMinimum + +fun LoadResponse.getId(): Int { + // this fixes an issue with outdated api as getLoadResponseIdFromUrl might be fucked + return (if (this is ResultViewModel2.LoadResponseFromSearch) this.id else null) + ?: getLoadResponseIdFromUrl(url, apiName) +} + +private fun getLoadResponseIdFromUrl(url: String, apiName: String): Int { + return url.replace(getApiFromNameNull(apiName)?.mainUrl ?: "", "").replace("/", "") + .hashCode() +} data class LinkProgress( val linksLoaded: Int, @@ -856,7 +874,7 @@ class ResultViewModel2 : ViewModel() { loadResponse: LoadResponse? = null, statusChangedCallback: ((statusChanged: Boolean) -> Unit)? = null ) { - val (response,currentId) = loadResponse?.let { load -> + val (response, currentId) = loadResponse?.let { load -> (load to load.getId()) } ?: ((currentResponse ?: return) to (currentId ?: return)) @@ -1140,12 +1158,16 @@ class ResultViewModel2 : ViewModel() { val message = if (duplicateEntries.size == 1) { val list = when (listType) { - LibraryListType.BOOKMARKS -> getResultWatchState(duplicateEntries[0].id ?: 0).stringRes + LibraryListType.BOOKMARKS -> getResultWatchState( + duplicateEntries[0].id ?: 0 + ).stringRes + LibraryListType.FAVORITES -> R.string.favorites_list_name LibraryListType.SUBSCRIPTIONS -> R.string.subscription_list_name } - context.getString(R.string.duplicate_message_single, + context.getString( + R.string.duplicate_message_single, "${normalizeString(duplicateEntries[0].name)} (${context.getString(list)}) — ${duplicateEntries[0].apiName}" ) } else { @@ -1170,9 +1192,11 @@ class ResultViewModel2 : ViewModel() { DialogInterface.BUTTON_POSITIVE -> { checkDuplicatesCallback.invoke(true, emptyList()) } + DialogInterface.BUTTON_NEGATIVE -> { checkDuplicatesCallback.invoke(false, emptyList()) } + DialogInterface.BUTTON_NEUTRAL -> { checkDuplicatesCallback.invoke(true, duplicateEntries.map { it.id }) } @@ -1189,17 +1213,17 @@ class ResultViewModel2 : ViewModel() { private fun getImdbIdFromSyncData(syncData: Map?): String? { return normalSafeApiCall { - SimklApi.readIdFromString( + readIdFromString( syncData?.get(AccountManager.simklApi.idPrefix) - )[SimklApi.Companion.SyncServices.Imdb] + )[SimklSyncServices.Imdb] } } private fun getTMDbIdFromSyncData(syncData: Map?): String? { return normalSafeApiCall { - SimklApi.readIdFromString( + readIdFromString( syncData?.get(AccountManager.simklApi.idPrefix) - )[SimklApi.Companion.SyncServices.Tmdb] + )[SimklSyncServices.Tmdb] } } @@ -1303,7 +1327,8 @@ class ResultViewModel2 : ViewModel() { postPopup( text, links.links.apmap { - val size = it.getVideoSize()?.let { size -> " " + formatFileSize(context, size) } ?: "" + val size = + it.getVideoSize()?.let { size -> " " + formatFileSize(context, size) } ?: "" txt("${it.name} ${Qualities.getStringByInt(it.quality)}$size") }) { callback.invoke(links to (it ?: return@postPopup)) @@ -1928,7 +1953,8 @@ class ResultViewModel2 : ViewModel() { .distinct().map { // this actually would be nice if we improved a bit as 3rd season == season 3 == III ect // right now it just removes the dubbed status - it.lowercase().replace(Regex("""\(?[ds]ub(bed)?\)?(\s|$)""") , "").trim() + it.lowercase().replace(Regex("""\(?[ds]ub(bed)?\)?(\s|$)"""), "") + .trim() }, TrackerType.getTypes(this.type), this.year @@ -2276,7 +2302,7 @@ class ResultViewModel2 : ViewModel() { private suspend fun postSuccessful( loadResponse: LoadResponse, - mainId : Int, + mainId: Int, apiRepository: APIRepository, updateEpisodes: Boolean, updateFillers: Boolean, @@ -2292,7 +2318,11 @@ class ResultViewModel2 : ViewModel() { postEpisodes(loadResponse, mainId, updateFillers) } - private suspend fun postEpisodes(loadResponse: LoadResponse, mainId : Int, updateFillers: Boolean) { + private suspend fun postEpisodes( + loadResponse: LoadResponse, + mainId: Int, + updateFillers: Boolean + ) { _episodes.postValue(Resource.Loading()) if (updateFillers && loadResponse is AnimeLoadResponse) { @@ -2313,7 +2343,12 @@ class ResultViewModel2 : ViewModel() { ?: 0) val totalIndex = - i.season?.let { season -> loadResponse.getTotalEpisodeIndex(episode, season) } + i.season?.let { season -> + loadResponse.getTotalEpisodeIndex( + episode, + season + ) + } if (!existingEpisodes.contains(id)) { existingEpisodes.add(id) @@ -2366,7 +2401,12 @@ class ResultViewModel2 : ViewModel() { loadResponse.seasonNames.getSeason(episode.season) val totalIndex = - episode.season?.let { season -> loadResponse.getTotalEpisodeIndex(episodeIndex, season) } + episode.season?.let { season -> + loadResponse.getTotalEpisodeIndex( + episodeIndex, + season + ) + } val ep = buildResultEpisode( @@ -2546,7 +2586,13 @@ class ResultViewModel2 : ViewModel() { ResumeProgress( progress = (viewPos.position / 1000).toInt(), maxProgress = (viewPos.duration / 1000).toInt(), - txt(R.string.resume_remaining, secondsToReadable(((viewPos.duration - viewPos.position) / 1_000).toInt(), "0 mins")) + txt( + R.string.resume_remaining, + secondsToReadable( + ((viewPos.duration - viewPos.position) / 1_000).toInt(), + "0 mins" + ) + ) ) } @@ -2672,17 +2718,26 @@ class ResultViewModel2 : ViewModel() { override var posterHeaders: Map? = null, override var backgroundPosterUrl: String? = null, override var contentRating: String? = null, - val id : Int?, + val id: Int?, ) : LoadResponse - fun loadSmall(activity: Activity?, searchResponse : SearchResponse) = ioSafe { + fun loadSmall(activity: Activity?, searchResponse: SearchResponse) = ioSafe { val url = searchResponse.url _page.postValue(Resource.Loading(url)) _episodes.postValue(Resource.Loading()) - val api = APIHolder.getApiFromNameNull(searchResponse.apiName) ?: APIHolder.getApiFromUrlNull(searchResponse.url) ?: APIRepository.noneApi + val api = + APIHolder.getApiFromNameNull(searchResponse.apiName) ?: APIHolder.getApiFromUrlNull( + searchResponse.url + ) ?: APIRepository.noneApi val repo = APIRepository(api) - val response = LoadResponseFromSearch(name = searchResponse.name, url = searchResponse.url, apiName = api.name, type = searchResponse.type ?: TvType.Others, - posterUrl = searchResponse.posterUrl, id = searchResponse.id).apply { + val response = LoadResponseFromSearch( + name = searchResponse.name, + url = searchResponse.url, + apiName = api.name, + type = searchResponse.type ?: TvType.Others, + posterUrl = searchResponse.posterUrl, + id = searchResponse.id + ).apply { if (searchResponse is SyncAPI.LibraryItem) { this.plot = searchResponse.plot this.rating = searchResponse.personalRating?.times(100) ?: searchResponse.rating @@ -2701,7 +2756,8 @@ class ResultViewModel2 : ViewModel() { mainId = mainId, apiRepository = repo, updateEpisodes = false, - updateFillers = false) + updateFillers = false + ) } fun load( diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt index e0762cc5..70919943 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/UiText.kt @@ -10,7 +10,7 @@ import androidx.annotation.StringRes import androidx.core.view.isGone import androidx.core.view.isVisible import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.utils.AppUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.html import com.lagradost.cloudstream3.utils.UIHelper.setImage sealed class UiText { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt index 24e87d30..ef10fcee 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchFragment.kt @@ -24,11 +24,7 @@ import androidx.recyclerview.widget.RecyclerView import com.google.android.material.bottomsheet.BottomSheetBehavior import com.google.android.material.bottomsheet.BottomSheetDialog import com.google.android.material.button.MaterialButton -import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia -import com.lagradost.cloudstream3.APIHolder.filterSearchResultByFilmQuality import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings -import com.lagradost.cloudstream3.APIHolder.getApiSettings import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.AcraApplication.Companion.removeKeys import com.lagradost.cloudstream3.AllLanguagesName @@ -58,9 +54,13 @@ import com.lagradost.cloudstream3.ui.result.setLinearListLayout import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.ownHide -import com.lagradost.cloudstream3.utils.AppUtils.ownShow -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia +import com.lagradost.cloudstream3.utils.AppContextUtils.filterSearchResultByFilmQuality +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiSettings +import com.lagradost.cloudstream3.utils.AppContextUtils.ownHide +import com.lagradost.cloudstream3.utils.AppContextUtils.ownShow +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.currentAccount diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt index 66423982..ef1b8719 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchHelper.kt @@ -11,7 +11,7 @@ import com.lagradost.cloudstream3.ui.download.DownloadClickEvent import com.lagradost.cloudstream3.ui.result.START_ACTION_LOAD_EP import com.lagradost.cloudstream3.ui.settings.Globals.PHONE import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.loadSearchResult +import com.lagradost.cloudstream3.utils.AppContextUtils.loadSearchResult import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.VideoDownloadHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt index d18c0197..f597132b 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/search/SearchResultBuilder.kt @@ -19,7 +19,7 @@ import com.lagradost.cloudstream3.isMovieType import com.lagradost.cloudstream3.syncproviders.SyncAPI import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.getNameFull +import com.lagradost.cloudstream3.utils.AppContextUtils.getNameFull import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.DataStoreHelper.fixVisual import com.lagradost.cloudstream3.utils.SubtitleHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt index 67a2a15b..15f8735f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsAccount.kt @@ -9,8 +9,6 @@ import android.view.inputmethod.EditorInfo import android.widget.TextView import androidx.annotation.UiThread import androidx.appcompat.app.AlertDialog -import androidx.core.content.ContextCompat -import androidx.core.graphics.drawable.toBitmapOrNull import androidx.core.view.isGone import androidx.core.view.isVisible import androidx.fragment.app.FragmentActivity @@ -49,7 +47,7 @@ import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.hideOn import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar -import com.lagradost.cloudstream3.utils.AppUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.html import com.lagradost.cloudstream3.utils.BackupUtils import com.lagradost.cloudstream3.utils.BiometricAuthenticator.BiometricCallback import com.lagradost.cloudstream3.utils.BiometricAuthenticator.authCallback @@ -64,9 +62,7 @@ import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard import com.lagradost.cloudstream3.utils.UIHelper.setImage -import com.lagradost.cloudstream3.utils.UIHelper.toPx import qrcode.QRCode -import java.io.ByteArrayOutputStream class SettingsAccount : PreferenceFragmentCompat(), BiometricCallback { companion object { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsProviders.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsProviders.kt index 7dc73a46..cfb46c39 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsProviders.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/SettingsProviders.kt @@ -7,19 +7,17 @@ import androidx.navigation.fragment.findNavController import androidx.preference.PreferenceFragmentCompat import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.APIHolder.getApiDubstatusSettings -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings -import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.ui.APIRepository import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.getPref import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setPaddingBottom import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiDubstatusSettings +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings import com.lagradost.cloudstream3.utils.DataStoreHelper import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.cloudstream3.utils.UIHelper.hideKeyboard -import com.lagradost.cloudstream3.utils.UIHelper.navigate class SettingsProviders : PreferenceFragmentCompat() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt index 1364c376..1b487629 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/ExtensionsFragment.kt @@ -33,8 +33,8 @@ import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar -import com.lagradost.cloudstream3.utils.AppUtils.addRepositoryDialog -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.addRepositoryDialog +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt index cab029bb..909c30be 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginAdapter.kt @@ -20,7 +20,7 @@ import com.lagradost.cloudstream3.ui.result.setText import com.lagradost.cloudstream3.ui.result.txt import com.lagradost.cloudstream3.ui.settings.Globals.TV import com.lagradost.cloudstream3.ui.settings.Globals.isLayout -import com.lagradost.cloudstream3.utils.AppUtils.html +import com.lagradost.cloudstream3.utils.AppContextUtils.html import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.main import com.lagradost.cloudstream3.utils.SubtitleHelper.fromTwoLettersToLanguage diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt index 3bdcb251..c5319c37 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/extensions/PluginsFragment.kt @@ -8,7 +8,6 @@ import androidx.appcompat.widget.SearchView import androidx.core.view.isVisible import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings import com.lagradost.cloudstream3.AllLanguagesName import com.lagradost.cloudstream3.BuildConfig import com.lagradost.cloudstream3.R @@ -24,6 +23,7 @@ import com.lagradost.cloudstream3.ui.settings.Globals.isLayout import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setToolBarScrollFlags import com.lagradost.cloudstream3.ui.settings.SettingsFragment.Companion.setUpToolbar import com.lagradost.cloudstream3.ui.settings.appLanguages +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings import com.lagradost.cloudstream3.utils.SingleSelectionHelper.showMultiDialog import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.cloudstream3.utils.UIHelper.toPx diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestResultAdapter.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestResultAdapter.kt index 023ecb4c..bad58a0e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestResultAdapter.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestResultAdapter.kt @@ -15,7 +15,7 @@ import com.lagradost.cloudstream3.databinding.ProviderTestItemBinding import com.lagradost.cloudstream3.mvvm.getAllMessages import com.lagradost.cloudstream3.mvvm.getStackTracePretty import com.lagradost.cloudstream3.plugins.PluginManager -import com.lagradost.cloudstream3.utils.AppUtils +import com.lagradost.cloudstream3.utils.AppContextUtils import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.Coroutines.runOnMainThread import com.lagradost.cloudstream3.utils.SubtitleHelper.getFlagFromIso @@ -23,7 +23,7 @@ import com.lagradost.cloudstream3.utils.TestingUtils import java.io.File class TestResultAdapter(override val items: MutableList>) : - AppUtils.DiffAdapter>(items) { + AppContextUtils.DiffAdapter>(items) { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder { return ProviderTestViewHolder( ProviderTestItemBinding.inflate(LayoutInflater.from(parent.context), parent, false) diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestView.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestView.kt index 26513f4a..eea495a2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestView.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/settings/testing/TestView.kt @@ -13,7 +13,7 @@ import androidx.core.view.isVisible import androidx.core.widget.ContentLoadingProgressBar import com.google.android.material.button.MaterialButton import com.lagradost.cloudstream3.R -import com.lagradost.cloudstream3.utils.AppUtils.animateProgressTo +import com.lagradost.cloudstream3.utils.AppContextUtils.animateProgressTo class TestView @JvmOverloads constructor( context: Context, diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt index 59dcc402..c12e9eb8 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/setup/SetupFragmentProviderLanguage.kt @@ -11,11 +11,11 @@ import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import androidx.preference.PreferenceManager import com.lagradost.cloudstream3.APIHolder -import com.lagradost.cloudstream3.APIHolder.getApiProviderLangSettings import com.lagradost.cloudstream3.AllLanguagesName import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.databinding.FragmentSetupProviderLanguagesBinding import com.lagradost.cloudstream3.mvvm.normalSafeApiCall +import com.lagradost.cloudstream3.utils.AppContextUtils.getApiProviderLangSettings import com.lagradost.cloudstream3.utils.SubtitleHelper import com.lagradost.cloudstream3.utils.UIHelper.fixPaddingStatusbar diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt similarity index 82% rename from app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt rename to app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt index 626eca12..f0aae7bc 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/AppUtils.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/AppContextUtils.kt @@ -51,6 +51,7 @@ import com.google.android.gms.common.GoogleApiAvailability import com.google.android.gms.common.wrappers.Wrappers import com.google.android.material.bottomsheet.BottomSheetDialog import com.lagradost.cloudstream3.* +import com.lagradost.cloudstream3.APIHolder.apis import com.lagradost.cloudstream3.CommonActivity.activity import com.lagradost.cloudstream3.CommonActivity.showToast import com.lagradost.cloudstream3.MainActivity.Companion.afterRepositoryLoadedEvent @@ -60,9 +61,9 @@ import com.lagradost.cloudstream3.plugins.RepositoryManager import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.appStringResumeWatching import com.lagradost.cloudstream3.syncproviders.providers.Kitsu import com.lagradost.cloudstream3.ui.WebviewFragment +import com.lagradost.cloudstream3.ui.player.SubtitleData import com.lagradost.cloudstream3.ui.result.ResultFragment import com.lagradost.cloudstream3.ui.settings.Globals -import com.lagradost.cloudstream3.ui.settings.extensions.ExtensionsFragment import com.lagradost.cloudstream3.ui.settings.extensions.PluginsFragment import com.lagradost.cloudstream3.ui.settings.extensions.RepositoryData import com.lagradost.cloudstream3.utils.Coroutines.ioSafe @@ -79,7 +80,7 @@ import java.io.* import java.net.URL import java.net.URLDecoder -object AppUtils { +object AppContextUtils { fun RecyclerView.setMaxViewPoolSize(maxViewTypeId: Int, maxPoolSize: Int) { for (i in 0..maxViewTypeId) recycledViewPool.setMaxRecycledViews(i, maxPoolSize) @@ -371,6 +372,168 @@ object AppUtils { } } + fun sortSubs(subs: Set): List { + return subs.sortedBy { it.name } + } + + fun Context.getApiSettings(): HashSet { + //val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + + val hashSet = HashSet() + val activeLangs = getApiProviderLangSettings() + val hasUniversal = activeLangs.contains(AllLanguagesName) + hashSet.addAll(synchronized(apis) { apis.filter { hasUniversal || activeLangs.contains(it.lang) } } + .map { it.name }) + + /*val set = settingsManager.getStringSet( + this.getString(R.string.search_providers_list_key), + hashSet + )?.toHashSet() ?: hashSet + + val list = HashSet() + for (name in set) { + val api = getApiFromNameNull(name) ?: continue + if (activeLangs.contains(api.lang)) { + list.add(name) + } + }*/ + //if (list.isEmpty()) return hashSet + //return list + return hashSet + } + + fun Context.getApiDubstatusSettings(): HashSet { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + val hashSet = HashSet() + hashSet.addAll(DubStatus.values()) + val list = settingsManager.getStringSet( + this.getString(R.string.display_sub_key), + hashSet.map { it.name }.toMutableSet() + ) ?: return hashSet + + val names = DubStatus.values().map { it.name }.toHashSet() + //if(realSet.isEmpty()) return hashSet + + return list.filter { names.contains(it) }.map { DubStatus.valueOf(it) }.toHashSet() + } + + fun Context.getApiProviderLangSettings(): HashSet { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + val hashSet = hashSetOf(AllLanguagesName) // def is all languages +// hashSet.add("en") // def is only en + val list = settingsManager.getStringSet( + this.getString(R.string.provider_lang_key), + hashSet + ) + + if (list.isNullOrEmpty()) return hashSet + return list.toHashSet() + } + + fun Context.getApiTypeSettings(): HashSet { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + val hashSet = HashSet() + hashSet.addAll(TvType.values()) + val list = settingsManager.getStringSet( + this.getString(R.string.search_types_list_key), + hashSet.map { it.name }.toMutableSet() + ) + + if (list.isNullOrEmpty()) return hashSet + + val names = TvType.values().map { it.name }.toHashSet() + val realSet = list.filter { names.contains(it) }.map { TvType.valueOf(it) }.toHashSet() + if (realSet.isEmpty()) return hashSet + + return realSet + } + + fun Context.updateHasTrailers() { + LoadResponse.isTrailersEnabled = getHasTrailers() + } + + private fun Context.getHasTrailers(): Boolean { + val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) + return settingsManager.getBoolean(this.getString(R.string.show_trailers_key), true) + } + + fun Context.filterProviderByPreferredMedia(hasHomePageIsRequired: Boolean = true): List { + // We are getting the weirdest crash ever done: + // java.lang.ClassCastException: com.lagradost.cloudstream3.TvType cannot be cast to com.lagradost.cloudstream3.TvType + // Trying fixing using classloader fuckery + val oldLoader = Thread.currentThread().contextClassLoader + Thread.currentThread().contextClassLoader = TvType::class.java.classLoader + + val default = TvType.values() + .sorted() + .filter { it != TvType.NSFW } + .map { it.ordinal } + + Thread.currentThread().contextClassLoader = oldLoader + + val defaultSet = default.map { it.toString() }.toSet() + val currentPrefMedia = try { + PreferenceManager.getDefaultSharedPreferences(this) + .getStringSet(this.getString(R.string.prefer_media_type_key), defaultSet) + ?.mapNotNull { it.toIntOrNull() ?: return@mapNotNull null } + } catch (e: Throwable) { + null + } ?: default + val langs = this.getApiProviderLangSettings() + val hasUniversal = langs.contains(AllLanguagesName) + val allApis = synchronized(apis) { + apis.filter { api -> (hasUniversal || langs.contains(api.lang)) && (api.hasMainPage || !hasHomePageIsRequired) } + } + return if (currentPrefMedia.isEmpty()) { + allApis + } else { + // Filter API depending on preferred media type + allApis.filter { api -> api.supportedTypes.any { currentPrefMedia.contains(it.ordinal) } } + } + } + + fun Context.filterSearchResultByFilmQuality(data: List): List { + // Filter results omitting entries with certain quality + if (data.isNotEmpty()) { + val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this) + ?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf()) + ?.mapNotNull { entry -> + entry.toIntOrNull() ?: return@mapNotNull null + } ?: listOf() + if (filteredSearchQuality.isNotEmpty()) { + return data.filter { item -> + val searchQualVal = item.quality?.ordinal ?: -1 + //Log.i("filterSearch", "QuickSearch item => ${item.toJson()}") + !filteredSearchQuality.contains(searchQualVal) + } + } + } + return data + } + + fun Context.filterHomePageListByFilmQuality(data: HomePageList): HomePageList { + // Filter results omitting entries with certain quality + if (data.list.isNotEmpty()) { + val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this) + ?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf()) + ?.mapNotNull { entry -> + entry.toIntOrNull() ?: return@mapNotNull null + } ?: listOf() + if (filteredSearchQuality.isNotEmpty()) { + return HomePageList( + name = data.name, + isHorizontalImages = data.isHorizontalImages, + list = data.list.filter { item -> + val searchQualVal = item.quality?.ordinal ?: -1 + //Log.i("filterSearch", "QuickSearch item => ${item.toJson()}") + !filteredSearchQuality.contains(searchQualVal) + } + ) + } + } + return data + } + fun Activity.loadRepository(url: String) { ioSafe { val repo = RepositoryManager.parseRepository(url) ?: return@ioSafe @@ -532,24 +695,6 @@ object AppUtils { return queryPairs } - /** Any object as json string */ - fun Any.toJson(): String { - if (this is String) return this - return mapper.writeValueAsString(this) - } - - inline fun parseJson(value: String): T { - return mapper.readValue(value) - } - - inline fun tryParseJson(value: String?): T? { - return try { - parseJson(value ?: return null) - } catch (_: Exception) { - null - } - } - /**| S1:E2 Hello World * | Episode 2. Hello world * | Hello World @@ -619,7 +764,7 @@ object AppUtils { val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) Kitsu.isEnabled = settingsManager.getBoolean(this.getString(R.string.show_kitsu_posters_key), true) - }catch (t : Throwable) { + } catch (t: Throwable) { logError(t) } diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt index 04387d80..43124a53 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/DataStoreHelper.kt @@ -3,7 +3,6 @@ package com.lagradost.cloudstream3.utils import android.content.Context import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.* -import com.lagradost.cloudstream3.APIHolder.filterProviderByPreferredMedia import com.lagradost.cloudstream3.APIHolder.unixTimeMS import com.lagradost.cloudstream3.AcraApplication.Companion.context import com.lagradost.cloudstream3.AcraApplication.Companion.getKey @@ -18,6 +17,7 @@ import com.lagradost.cloudstream3.ui.WatchType import com.lagradost.cloudstream3.ui.library.ListSorting import com.lagradost.cloudstream3.ui.result.UiImage import com.lagradost.cloudstream3.ui.result.VideoWatchState +import com.lagradost.cloudstream3.utils.AppContextUtils.filterProviderByPreferredMedia import kotlin.reflect.KClass import kotlin.reflect.KProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt index d9a31b4e..89bb0031 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/InAppUpdater.kt @@ -24,7 +24,7 @@ import okio.sink import java.io.File import android.text.TextUtils import com.lagradost.cloudstream3.MainActivity.Companion.deleteFileOnExit -import com.lagradost.cloudstream3.utils.AppUtils.setDefaultFocus +import com.lagradost.cloudstream3.utils.AppContextUtils.setDefaultFocus import java.io.BufferedReader import java.io.IOException import java.io.InputStreamReader diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/PackageInstallerService.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/PackageInstallerService.kt index 322547f4..57b98dc2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/PackageInstallerService.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/PackageInstallerService.kt @@ -15,7 +15,7 @@ import com.lagradost.cloudstream3.MainActivity import com.lagradost.cloudstream3.MainActivity.Companion.deleteFileOnExit import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.app -import com.lagradost.cloudstream3.utils.AppUtils.createNotificationChannel +import com.lagradost.cloudstream3.utils.AppContextUtils.createNotificationChannel import com.lagradost.cloudstream3.utils.Coroutines.ioSafe import com.lagradost.cloudstream3.utils.UIHelper.colorFromAttribute import kotlinx.coroutines.delay diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt index 421b09e2..f3cbdaf1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/utils/VideoDownloadManager.kt @@ -24,6 +24,7 @@ import com.lagradost.cloudstream3.APIHolder.getApiFromNameNull import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey import com.lagradost.cloudstream3.AcraApplication.Companion.setKey import com.lagradost.cloudstream3.BuildConfig +import com.lagradost.cloudstream3.IDownloadableMinimum import com.lagradost.cloudstream3.MainActivity import com.lagradost.cloudstream3.R import com.lagradost.cloudstream3.TvType @@ -107,16 +108,6 @@ object VideoDownloadManager { Stop, } - interface IDownloadableMinimum { - val url: String - val referer: String - val headers: Map - } - - fun IDownloadableMinimum.getId(): Int { - return url.hashCode() - } - data class DownloadEpisodeMetadata( @JsonProperty("id") val id: Int, @JsonProperty("mainName") val mainName: String, diff --git a/library/build.gradle.kts b/library/build.gradle.kts index 46da8e84..516e1ee9 100644 --- a/library/build.gradle.kts +++ b/library/build.gradle.kts @@ -1,4 +1,5 @@ import com.codingfeline.buildkonfig.compiler.FieldSpec +import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { kotlin("multiplatform") @@ -12,6 +13,11 @@ kotlin { androidTarget() jvm() + @OptIn(ExperimentalKotlinGradlePluginApi::class) + compilerOptions { + freeCompilerArgs.add("-Xexpect-actual-classes") + } + sourceSets { commonMain.dependencies { implementation("com.github.Blatzar:NiceHttp:0.4.11") // HTTP Lib @@ -19,6 +25,9 @@ kotlin { ^ Don't Bump Jackson above 2.13.1 , Crashes on Android TV's and FireSticks that have Min API Level 25 or Less. */ implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0") + implementation("me.xdrop:fuzzywuzzy:1.4.0") // Match extractors + implementation("org.mozilla:rhino:1.7.15") // run JavaScript + implementation("com.github.teamnewpipe:NewPipeExtractor:fafd471") } } } diff --git a/library/src/androidMain/kotlin/com/lagradost/api/ContextHelper.android.kt b/library/src/androidMain/kotlin/com/lagradost/api/ContextHelper.android.kt new file mode 100644 index 00000000..a8472fea --- /dev/null +++ b/library/src/androidMain/kotlin/com/lagradost/api/ContextHelper.android.kt @@ -0,0 +1,20 @@ +package com.lagradost.api + +import android.content.Context +import java.lang.ref.WeakReference + +var ctx: WeakReference? = null + +/** + * Helper function for Android specific context. Not usable in JVM. + * Do not use this unless absolutely necessary. + */ +actual fun getContext(): Any? { + return ctx?.get() +} + +actual fun setContext(context: WeakReference) { + if (context.get() is Context) { + ctx = context as? WeakReference + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/network/WebViewResolver.kt b/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt similarity index 90% rename from app/src/main/java/com/lagradost/cloudstream3/network/WebViewResolver.kt rename to library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt index 90872d94..0fbc5749 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/network/WebViewResolver.kt +++ b/library/src/androidMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.android.kt @@ -1,13 +1,12 @@ package com.lagradost.cloudstream3.network import android.annotation.SuppressLint +import android.content.Context import android.net.http.SslError import android.os.Handler import android.os.Looper import android.webkit.* -import com.lagradost.cloudstream3.AcraApplication -import com.lagradost.cloudstream3.AcraApplication.Companion.context -import com.lagradost.cloudstream3.USER_AGENT +import com.lagradost.api.getContext import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.mvvm.debugException import com.lagradost.cloudstream3.mvvm.logError @@ -33,40 +32,24 @@ import java.net.URI * @param scriptCallback will be called with the result from custom js * @param timeout close webview after timeout * */ -class WebViewResolver( +actual class WebViewResolver actual constructor( val interceptUrl: Regex, - val additionalUrls: List = emptyList(), - val userAgent: String? = USER_AGENT, - val useOkhttp: Boolean = true, - val script: String? = null, - val scriptCallback: ((String) -> Unit)? = null, - val timeout: Long = DEFAULT_TIMEOUT + val additionalUrls: List, + val userAgent: String?, + val useOkhttp: Boolean, + val script: String?, + val scriptCallback: ((String) -> Unit)?, + val timeout: Long ) : Interceptor { - constructor( - interceptUrl: Regex, - additionalUrls: List = emptyList(), - userAgent: String? = USER_AGENT, - useOkhttp: Boolean = true, - script: String? = null, - scriptCallback: ((String) -> Unit)? = null, - ) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, script, scriptCallback, DEFAULT_TIMEOUT) - - constructor( - interceptUrl: Regex, - additionalUrls: List = emptyList(), - userAgent: String? = USER_AGENT, - useOkhttp: Boolean = true - ) : this(interceptUrl, additionalUrls, userAgent, useOkhttp, null, null, DEFAULT_TIMEOUT) - - companion object { - private const val DEFAULT_TIMEOUT = 60_000L + actual companion object { var webViewUserAgent: String? = null + actual val DEFAULT_TIMEOUT = 60_000L @JvmName("getWebViewUserAgent1") fun getWebViewUserAgent(): String? { - return webViewUserAgent ?: context?.let { ctx -> + return webViewUserAgent ?: (getContext() as? Context)?.let { ctx -> runBlocking { mainWork { WebView(ctx).settings.userAgentString.also { userAgent -> @@ -137,7 +120,7 @@ class WebViewResolver( WebView.setWebContentsDebuggingEnabled(true) try { webView = WebView( - AcraApplication.context + (getContext() as? Context) ?: throw RuntimeException("No base context in WebViewResolver") ).apply { // Bare minimum to bypass captcha diff --git a/library/src/commonMain/kotlin/com/lagradost/api/ContextHelper.kt b/library/src/commonMain/kotlin/com/lagradost/api/ContextHelper.kt new file mode 100644 index 00000000..fb54e3ca --- /dev/null +++ b/library/src/commonMain/kotlin/com/lagradost/api/ContextHelper.kt @@ -0,0 +1,16 @@ +package com.lagradost.api + +import java.lang.ref.WeakReference + +/** + * Set context for android specific code such as webview. + * Does nothing on JVM. + */ +expect fun setContext(context: WeakReference) +/** + * Helper function for Android specific context. + * Do not use this unless absolutely necessary. + * setContext() must be called before this is called. + * @return Context if on android, null if not. + */ +expect fun getContext(): Any? diff --git a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt similarity index 86% rename from app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt index 91da2ed0..47ef5382 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/MainAPI.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/MainAPI.kt @@ -1,34 +1,26 @@ package com.lagradost.cloudstream3 -import android.annotation.SuppressLint -import android.content.Context -import android.net.Uri -import android.util.Base64.encodeToString -import androidx.annotation.WorkerThread -import androidx.preference.PreferenceManager import com.fasterxml.jackson.annotation.JsonProperty import com.fasterxml.jackson.databind.DeserializationFeature import com.fasterxml.jackson.databind.json.JsonMapper import com.fasterxml.jackson.module.kotlin.kotlinModule import com.lagradost.cloudstream3.mvvm.logError import com.lagradost.cloudstream3.mvvm.normalSafeApiCall -import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.aniListApi -import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.malApi -import com.lagradost.cloudstream3.syncproviders.AccountManager.Companion.simklApi import com.lagradost.cloudstream3.syncproviders.SyncIdName -import com.lagradost.cloudstream3.syncproviders.providers.SimklApi -import com.lagradost.cloudstream3.ui.player.SubtitleData -import com.lagradost.cloudstream3.ui.result.ResultViewModel2 import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.utils.AppUtils.toJson +import com.lagradost.cloudstream3.utils.AppUtils.tryParseJson import com.lagradost.cloudstream3.utils.Coroutines.mainWork import com.lagradost.cloudstream3.utils.Coroutines.threadSafeListOf import com.lagradost.nicehttp.RequestBodyTypes import okhttp3.Interceptor import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.RequestBody.Companion.toRequestBody +import java.net.URI import java.text.SimpleDateFormat import java.util.* +import kotlin.io.encoding.Base64 +import kotlin.io.encoding.ExperimentalEncodingApi import kotlin.math.absoluteValue /** @@ -111,17 +103,6 @@ object APIHolder { return null } - private fun getLoadResponseIdFromUrl(url: String, apiName: String): Int { - return url.replace(getApiFromNameNull(apiName)?.mainUrl ?: "", "").replace("/", "") - .hashCode() - } - - fun LoadResponse.getId(): Int { - // this fixes an issue with outdated api as getLoadResponseIdFromUrl might be fucked - return (if (this is ResultViewModel2.LoadResponseFromSearch) this.id else null) - ?: getLoadResponseIdFromUrl(url, apiName) - } - /** * Gets the website captcha token * discovered originally by https://github.com/ahmedgamal17 @@ -137,10 +118,9 @@ object APIHolder { // To get the key suspend fun getCaptchaToken(url: String, key: String, referer: String? = null): String? { try { - val uri = Uri.parse(url) - val domain = encodeToString( + val uri = URI.create(url) + val domain = base64Encode( (uri.scheme + "://" + uri.host + ":443").encodeToByteArray(), - 0 ).replace("\n", "").replace("=", ".") val vToken = @@ -275,165 +255,6 @@ object APIHolder { return app.post("https://graphql.anilist.co", requestBody = data) .parsedSafe() } - - - fun Context.getApiSettings(): HashSet { - //val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - - val hashSet = HashSet() - val activeLangs = getApiProviderLangSettings() - val hasUniversal = activeLangs.contains(AllLanguagesName) - hashSet.addAll(synchronized(apis) { apis.filter { hasUniversal || activeLangs.contains(it.lang) } } - .map { it.name }) - - /*val set = settingsManager.getStringSet( - this.getString(R.string.search_providers_list_key), - hashSet - )?.toHashSet() ?: hashSet - - val list = HashSet() - for (name in set) { - val api = getApiFromNameNull(name) ?: continue - if (activeLangs.contains(api.lang)) { - list.add(name) - } - }*/ - //if (list.isEmpty()) return hashSet - //return list - return hashSet - } - - fun Context.getApiDubstatusSettings(): HashSet { - val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - val hashSet = HashSet() - hashSet.addAll(DubStatus.values()) - val list = settingsManager.getStringSet( - this.getString(R.string.display_sub_key), - hashSet.map { it.name }.toMutableSet() - ) ?: return hashSet - - val names = DubStatus.values().map { it.name }.toHashSet() - //if(realSet.isEmpty()) return hashSet - - return list.filter { names.contains(it) }.map { DubStatus.valueOf(it) }.toHashSet() - } - - fun Context.getApiProviderLangSettings(): HashSet { - val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - val hashSet = hashSetOf(AllLanguagesName) // def is all languages -// hashSet.add("en") // def is only en - val list = settingsManager.getStringSet( - this.getString(R.string.provider_lang_key), - hashSet - ) - - if (list.isNullOrEmpty()) return hashSet - return list.toHashSet() - } - - fun Context.getApiTypeSettings(): HashSet { - val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - val hashSet = HashSet() - hashSet.addAll(TvType.values()) - val list = settingsManager.getStringSet( - this.getString(R.string.search_types_list_key), - hashSet.map { it.name }.toMutableSet() - ) - - if (list.isNullOrEmpty()) return hashSet - - val names = TvType.values().map { it.name }.toHashSet() - val realSet = list.filter { names.contains(it) }.map { TvType.valueOf(it) }.toHashSet() - if (realSet.isEmpty()) return hashSet - - return realSet - } - - fun Context.updateHasTrailers() { - LoadResponse.isTrailersEnabled = getHasTrailers() - } - - private fun Context.getHasTrailers(): Boolean { - val settingsManager = PreferenceManager.getDefaultSharedPreferences(this) - return settingsManager.getBoolean(this.getString(R.string.show_trailers_key), true) - } - - fun Context.filterProviderByPreferredMedia(hasHomePageIsRequired: Boolean = true): List { - // We are getting the weirdest crash ever done: - // java.lang.ClassCastException: com.lagradost.cloudstream3.TvType cannot be cast to com.lagradost.cloudstream3.TvType - // Trying fixing using classloader fuckery - val oldLoader = Thread.currentThread().contextClassLoader - Thread.currentThread().contextClassLoader = TvType::class.java.classLoader - - val default = TvType.values() - .sorted() - .filter { it != TvType.NSFW } - .map { it.ordinal } - - Thread.currentThread().contextClassLoader = oldLoader - - val defaultSet = default.map { it.toString() }.toSet() - val currentPrefMedia = try { - PreferenceManager.getDefaultSharedPreferences(this) - .getStringSet(this.getString(R.string.prefer_media_type_key), defaultSet) - ?.mapNotNull { it.toIntOrNull() ?: return@mapNotNull null } - } catch (e: Throwable) { - null - } ?: default - val langs = this.getApiProviderLangSettings() - val hasUniversal = langs.contains(AllLanguagesName) - val allApis = synchronized(apis) { - apis.filter { api -> (hasUniversal || langs.contains(api.lang)) && (api.hasMainPage || !hasHomePageIsRequired) } - } - return if (currentPrefMedia.isEmpty()) { - allApis - } else { - // Filter API depending on preferred media type - allApis.filter { api -> api.supportedTypes.any { currentPrefMedia.contains(it.ordinal) } } - } - } - - fun Context.filterSearchResultByFilmQuality(data: List): List { - // Filter results omitting entries with certain quality - if (data.isNotEmpty()) { - val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this) - ?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf()) - ?.mapNotNull { entry -> - entry.toIntOrNull() ?: return@mapNotNull null - } ?: listOf() - if (filteredSearchQuality.isNotEmpty()) { - return data.filter { item -> - val searchQualVal = item.quality?.ordinal ?: -1 - //Log.i("filterSearch", "QuickSearch item => ${item.toJson()}") - !filteredSearchQuality.contains(searchQualVal) - } - } - } - return data - } - - fun Context.filterHomePageListByFilmQuality(data: HomePageList): HomePageList { - // Filter results omitting entries with certain quality - if (data.list.isNotEmpty()) { - val filteredSearchQuality = PreferenceManager.getDefaultSharedPreferences(this) - ?.getStringSet(getString(R.string.pref_filter_search_quality_key), setOf()) - ?.mapNotNull { entry -> - entry.toIntOrNull() ?: return@mapNotNull null - } ?: listOf() - if (filteredSearchQuality.isNotEmpty()) { - return HomePageList( - name = data.name, - isHorizontalImages = data.isHorizontalImages, - list = data.list.filter { item -> - val searchQualVal = item.quality?.ordinal ?: -1 - //Log.i("filterSearch", "QuickSearch item => ${item.toJson()}") - !filteredSearchQuality.contains(searchQualVal) - } - ) - } - } - return data - } } /* @@ -656,7 +477,7 @@ abstract class MainAPI { //emptyList() // open val mainPage = listOf(MainPageData("", "", false)) - @WorkerThread + // @WorkerThread open suspend fun getMainPage( page: Int, request: MainPageRequest, @@ -664,17 +485,17 @@ abstract class MainAPI { throw NotImplementedError() } - @WorkerThread + // @WorkerThread open suspend fun search(query: String): List? { throw NotImplementedError() } - @WorkerThread + // @WorkerThread open suspend fun quickSearch(query: String): List? { throw NotImplementedError() } - @WorkerThread + // @WorkerThread /** * Based on data from search() or getMainPage() it generates a LoadResponse, * basically opening the info page from a link. @@ -692,13 +513,13 @@ abstract class MainAPI { * This function might be updated to include exoplayer timestamps etc in the future * if the need arises. * */ - @WorkerThread + // @WorkerThread open suspend fun extractorVerifierJob(extractorData: String?) { throw NotImplementedError() } /**Callback is fired once a link is found, will return true if method is executed successfully*/ - @WorkerThread + // @WorkerThread open suspend fun loadLinks( data: String, isCasting: Boolean, @@ -723,27 +544,16 @@ abstract class MainAPI { } /** Might need a different implementation for desktop*/ -@SuppressLint("NewApi") fun base64Decode(string: String): String { return String(base64DecodeArray(string), Charsets.ISO_8859_1) } - -@SuppressLint("NewApi") +@OptIn(ExperimentalEncodingApi::class) fun base64DecodeArray(string: String): ByteArray { - return try { - android.util.Base64.decode(string, android.util.Base64.DEFAULT) - } catch (e: Exception) { - Base64.getDecoder().decode(string) - } + return Base64.decode(string) } - -@SuppressLint("NewApi") +@OptIn(ExperimentalEncodingApi::class) fun base64Encode(array: ByteArray): String { - return try { - String(android.util.Base64.encode(array, android.util.Base64.NO_WRAP), Charsets.ISO_8859_1) - } catch (e: Exception) { - String(Base64.getEncoder().encode(array)) - } + return Base64.encode(array) } fun MainAPI.fixUrlNull(url: String?): String? { @@ -779,10 +589,6 @@ fun sortUrls(urls: Set): List { return urls.sortedBy { t -> -t.quality } } -fun sortSubs(subs: Set): List { - return subs.sortedBy { it.name } -} - fun capitalizeString(str: String): String { return capitalizeStringNullable(str) ?: str } @@ -1204,11 +1010,25 @@ interface LoadResponse { var contentRating: String? companion object { - private val malIdPrefix = malApi.idPrefix - private val aniListIdPrefix = aniListApi.idPrefix - private val simklIdPrefix = simklApi.idPrefix + var malIdPrefix = "" //malApi.idPrefix + var aniListIdPrefix = "" //aniListApi.idPrefix + var simklIdPrefix = "" //simklApi.idPrefix var isTrailersEnabled = true + /** + * The ID string is a way to keep a collection of services in one single ID using a map + * This adds a database service (like imdb) to the string and returns the new string. + */ + fun addIdToString(idString: String?, database: SimklSyncServices, id: String?): String? { + if (id == null) return idString + return (readIdFromString(idString) + mapOf(database to id)).toJson() + } + + /** Read the id string to get all other ids */ + fun readIdFromString(idString: String?): Map { + return tryParseJson(idString) ?: return emptyMap() + } + fun LoadResponse.isMovie(): Boolean { return this.type.isMovieType() || this is MovieLoadResponse } @@ -1232,12 +1052,12 @@ interface LoadResponse { * Internal helper function to add simkl ids from other databases. */ private fun LoadResponse.addSimklId( - database: SimklApi.Companion.SyncServices, + database: SimklSyncServices, id: String? ) { normalSafeApiCall { this.syncData[simklIdPrefix] = - SimklApi.addIdToString(this.syncData[simklIdPrefix], database, id.toString()) + addIdToString(this.syncData[simklIdPrefix], database, id.toString()) ?: return@normalSafeApiCall } } @@ -1257,30 +1077,28 @@ interface LoadResponse { fun LoadResponse.getImdbId(): String? { return normalSafeApiCall { - SimklApi.readIdFromString(this.syncData[simklIdPrefix]) - ?.get(SimklApi.Companion.SyncServices.Imdb) + readIdFromString(this.syncData[simklIdPrefix])[SimklSyncServices.Imdb] } } fun LoadResponse.getTMDbId(): String? { return normalSafeApiCall { - SimklApi.readIdFromString(this.syncData[simklIdPrefix]) - ?.get(SimklApi.Companion.SyncServices.Tmdb) + readIdFromString(this.syncData[simklIdPrefix])[SimklSyncServices.Tmdb] } } fun LoadResponse.addMalId(id: Int?) { this.syncData[malIdPrefix] = (id ?: return).toString() - this.addSimklId(SimklApi.Companion.SyncServices.Mal, id.toString()) + this.addSimklId(SimklSyncServices.Mal, id.toString()) } fun LoadResponse.addAniListId(id: Int?) { this.syncData[aniListIdPrefix] = (id ?: return).toString() - this.addSimklId(SimklApi.Companion.SyncServices.AniList, id.toString()) + this.addSimklId(SimklSyncServices.AniList, id.toString()) } fun LoadResponse.addSimklId(id: Int?) { - this.addSimklId(SimklApi.Companion.SyncServices.Simkl, id.toString()) + this.addSimklId(SimklSyncServices.Simkl, id.toString()) } fun LoadResponse.addImdbUrl(url: String?) { @@ -1362,7 +1180,7 @@ interface LoadResponse { fun LoadResponse.addImdbId(id: String?) { // TODO add imdb sync - this.addSimklId(SimklApi.Companion.SyncServices.Imdb, id) + this.addSimklId(SimklSyncServices.Imdb, id) } fun LoadResponse.addTrackId(id: String?) { @@ -1375,7 +1193,7 @@ interface LoadResponse { fun LoadResponse.addTMDbId(id: String?) { // TODO add TMDb sync - this.addSimklId(SimklApi.Companion.SyncServices.Tmdb, id) + this.addSimklId(SimklSyncServices.Tmdb, id) } fun LoadResponse.addRating(text: String?) { @@ -1466,7 +1284,7 @@ data class NextAiring( constructor( episode: Int, unixTime: Long, - ) : this ( + ) : this( episode, unixTime, null @@ -1929,6 +1747,28 @@ fun MainAPI.newEpisode( return builder } +interface IDownloadableMinimum { + val url: String + val referer: String + val headers: Map +} + +fun IDownloadableMinimum.getId(): Int { + return url.hashCode() +} + +/** + * Set of sync services simkl is compatible with. + * Add more as required: https://simkl.docs.apiary.io/#reference/search/id-lookup/get-items-by-id + */ +enum class SimklSyncServices(val originalName: String) { + Simkl("simkl"), + Imdb("imdb"), + Tmdb("tmdb"), + AniList("anilist"), + Mal("mal"), +} + data class TvSeriesLoadResponse( override var name: String, override var url: String, diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/AStreamHub.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/AStreamHub.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/AStreamHub.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/AStreamHub.kt index b0051ba7..23f8dcf4 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/AStreamHub.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/AStreamHub.kt @@ -1,6 +1,6 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Acefile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Acefile.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Acefile.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Acefile.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/AsianLoad.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/AsianLoad.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/AsianLoad.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/AsianLoad.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Blogger.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Blogger.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Blogger.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/BullStream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/BullStream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/BullStream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/BullStream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/ByteShare.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByteShare.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/ByteShare.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ByteShare.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Cda.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Cda.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Cda.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Cda.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Chillx.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Chillx.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Chillx.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt index b7f84af1..27a5c52a 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/ContentXExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Dailymotion.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Dailymotion.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Dailymotion.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/DoodExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/DoodExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/DoodExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/EPlay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/EPlay.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/EPlay.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/EPlay.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Embedgram.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Embedgram.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Embedgram.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Embedgram.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/EmturbovidExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/EmturbovidExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/EmturbovidExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/EmturbovidExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Evolaod.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Evolaod.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Evolaod.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Evolaod.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Fastream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Fastream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Fastream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Fastream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Filesim.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Filesim.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Filesim.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Filesim.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GMPlayer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GMPlayer.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/GMPlayer.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GMPlayer.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gdriveplayer.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GenericM3U8.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GenericM3U8.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/GenericM3U8.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GenericM3U8.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Gofile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Gofile.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Gofile.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GoodstreamExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GoodstreamExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/GoodstreamExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GoodstreamExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GuardareStream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/GuardareStream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/GuardareStream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt index 03586386..1f70ce61 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDMomPlayerExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.lagradost.cloudstream3.extractors.helper.AesHelper diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt index 14333d35..8318c3fb 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDPlayerSystemExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/HDStreamAbleExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDStreamAbleExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/HDStreamAbleExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HDStreamAbleExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/HotlingerExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HotlingerExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/HotlingerExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/HotlingerExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Hxfile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Hxfile.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Hxfile.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Hxfile.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/JWPlayer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/JWPlayer.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/JWPlayer.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/JWPlayer.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Jawcloud.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jawcloud.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Jawcloud.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jawcloud.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Jeniusplay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Jeniusplay.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Jeniusplay.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Krakenfiles.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Krakenfiles.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Krakenfiles.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Krakenfiles.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Linkbox.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Linkbox.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Linkbox.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/M3u8Manifest.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/M3u8Manifest.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/M3u8Manifest.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/M3u8Manifest.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt index 766c7762..ce742e97 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MailRuExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Maxstream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Maxstream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Maxstream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Maxstream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Mediafire.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mediafire.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Mediafire.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mediafire.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Minoplres.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Minoplres.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Minoplres.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Minoplres.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/MixDrop.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MixDrop.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/MixDrop.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MixDrop.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Moviehab.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Moviehab.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Moviehab.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Moviehab.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Mp4Upload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mp4Upload.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Mp4Upload.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mp4Upload.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/MultiQuality.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MultiQuality.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/MultiQuality.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/MultiQuality.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Mvidoo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mvidoo.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Mvidoo.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Mvidoo.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt index 46f6ad0f..6db0830c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OdnoklassnikiExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/OkRuExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OkRuExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/OkRuExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/OkRuExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Okrulink.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Okrulink.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Okrulink.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Okrulink.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt similarity index 99% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt index b57449bf..0a005036 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PeaceMakerstExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Pelisplus.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Pelisplus.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Pelisplus.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Pelisplus.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/PixelDrainExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PixelDrainExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/PixelDrainExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PixelDrainExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt similarity index 99% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt index 2b286abb..a4dc694e 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayLtXyz.kt @@ -1,6 +1,6 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.* diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/PlayerVoxzer.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Rabbitstream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Rabbitstream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Rabbitstream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt index a0d830cf..607d2d78 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/RapidVidExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/SBPlay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SBPlay.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/SBPlay.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SBPlay.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Sendvid.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Sendvid.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Sendvid.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Sendvid.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt index a8bcee31..ebd57f9c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/SibNetExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Solidfiles.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Solidfiles.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Solidfiles.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Solidfiles.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamSB.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/StreamSB.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamSB.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamTape.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamTape.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/StreamTape.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamTape.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamWishExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Streamhub.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamhub.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Streamhub.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamhub.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Streamlare.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Streamlare.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamlare.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamoUpload.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/StreamoUpload.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/StreamoUpload.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Streamplay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Streamplay.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Streamplay.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Supervideo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Supervideo.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Supervideo.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Supervideo.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt index 645d7c0e..de5ca9a2 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TRsTXExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Tantifilm.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tantifilm.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt index 2478edc1..157374a3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/TauVideoExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Tomatomatela.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tomatomatela.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Tomatomatela.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Tomatomatela.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/UpstreamExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/UpstreamExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/UpstreamExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/UpstreamExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Uqload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uqload.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Uqload.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uqload.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Userload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Userload.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Userload.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Userload.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Userscloud.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Userscloud.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Userscloud.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Userscloud.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Uservideo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Uservideo.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Uservideo.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vicloud.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vicloud.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vicloud.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt index b963fe56..e57772ce 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidMoxyExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidSrcExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidSrcExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidSrcTo.kt similarity index 88% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidSrcTo.kt index 2655670d..73857fb3 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidSrcTo.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidSrcTo.kt @@ -1,70 +1,72 @@ -package com.lagradost.cloudstream3.extractors - -import android.util.Base64 -import com.fasterxml.jackson.annotation.JsonProperty -import com.lagradost.cloudstream3.SubtitleFile -import com.lagradost.cloudstream3.amap -import com.lagradost.cloudstream3.app -import com.lagradost.cloudstream3.mvvm.logError -import com.lagradost.cloudstream3.utils.ExtractorApi -import com.lagradost.cloudstream3.utils.ExtractorLink -import java.net.URLDecoder -import javax.crypto.Cipher -import javax.crypto.spec.SecretKeySpec - -class VidSrcTo : ExtractorApi() { - override val name = "VidSrcTo" - override val mainUrl = "https://vidsrc.to" - override val requiresReferer = true - - override suspend fun getUrl( - url: String, - referer: String?, - subtitleCallback: (SubtitleFile) -> Unit, - callback: (ExtractorLink) -> Unit - ) { - val mediaId = app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id") ?: return - val res = app.get("$mainUrl/ajax/embed/episode/$mediaId/sources").parsedSafe() ?: return - if (res.status != 200) return - res.result?.amap { source -> - try { - val embedRes = app.get("$mainUrl/ajax/embed/source/${source.id}").parsedSafe() ?: return@amap - val finalUrl = DecryptUrl(embedRes.result.encUrl) - if(finalUrl.equals(embedRes.result.encUrl)) return@amap - when (source.title) { - "Vidplay" -> AnyVidplay(finalUrl.substringBefore("/e/")).getUrl(finalUrl, referer, subtitleCallback, callback) - "Filemoon" -> FileMoon().getUrl(finalUrl, referer, subtitleCallback, callback) - } - } catch (e: Exception) { - logError(e) - } - } - } - - private fun DecryptUrl(encUrl: String): String { - var data = encUrl.toByteArray() - data = Base64.decode(data, Base64.URL_SAFE) - val rc4Key = SecretKeySpec("WXrUARXb1aDLaZjI".toByteArray(), "RC4") - val cipher = Cipher.getInstance("RC4") - cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters) - data = cipher.doFinal(data) - return URLDecoder.decode(data.toString(Charsets.UTF_8), "utf-8") - } - - data class VidsrctoEpisodeSources( - @JsonProperty("status") val status: Int, - @JsonProperty("result") val result: List? - ) - - data class VidsrctoResult( - @JsonProperty("id") val id: String, - @JsonProperty("title") val title: String - ) - - data class VidsrctoEmbedSource( - @JsonProperty("status") val status: Int, - @JsonProperty("result") val result: VidsrctoUrl - ) - - data class VidsrctoUrl(@JsonProperty("url") val encUrl: String) -} +package com.lagradost.cloudstream3.extractors + +import com.fasterxml.jackson.annotation.JsonProperty +import com.lagradost.cloudstream3.SubtitleFile +import com.lagradost.cloudstream3.amap +import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.base64Decode +import com.lagradost.cloudstream3.mvvm.logError +import com.lagradost.cloudstream3.utils.ExtractorApi +import com.lagradost.cloudstream3.utils.ExtractorLink +import java.net.URLDecoder +import javax.crypto.Cipher +import javax.crypto.spec.SecretKeySpec +import kotlin.io.encoding.Base64 +import kotlin.io.encoding.ExperimentalEncodingApi + +class VidSrcTo : ExtractorApi() { + override val name = "VidSrcTo" + override val mainUrl = "https://vidsrc.to" + override val requiresReferer = true + + override suspend fun getUrl( + url: String, + referer: String?, + subtitleCallback: (SubtitleFile) -> Unit, + callback: (ExtractorLink) -> Unit + ) { + val mediaId = app.get(url).document.selectFirst("ul.episodes li a")?.attr("data-id") ?: return + val res = app.get("$mainUrl/ajax/embed/episode/$mediaId/sources").parsedSafe() ?: return + if (res.status != 200) return + res.result?.amap { source -> + try { + val embedRes = app.get("$mainUrl/ajax/embed/source/${source.id}").parsedSafe() ?: return@amap + val finalUrl = DecryptUrl(embedRes.result.encUrl) + if(finalUrl.equals(embedRes.result.encUrl)) return@amap + when (source.title) { + "Vidplay" -> AnyVidplay(finalUrl.substringBefore("/e/")).getUrl(finalUrl, referer, subtitleCallback, callback) + "Filemoon" -> FileMoon().getUrl(finalUrl, referer, subtitleCallback, callback) + } + } catch (e: Exception) { + logError(e) + } + } + } + + @OptIn(ExperimentalEncodingApi::class) + private fun DecryptUrl(encUrl: String): String { + val data = Base64.UrlSafe.decode(encUrl) + val rc4Key = SecretKeySpec("WXrUARXb1aDLaZjI".toByteArray(), "RC4") + val cipher = Cipher.getInstance("RC4") + cipher.init(Cipher.DECRYPT_MODE, rc4Key, cipher.parameters) + val finalData = cipher.doFinal(data) + return URLDecoder.decode(finalData.toString(Charsets.UTF_8), "utf-8") + } + + data class VidsrctoEpisodeSources( + @JsonProperty("status") val status: Int, + @JsonProperty("result") val result: List? + ) + + data class VidsrctoResult( + @JsonProperty("id") val id: String, + @JsonProperty("title") val title: String + ) + + data class VidsrctoEmbedSource( + @JsonProperty("status") val status: Int, + @JsonProperty("result") val result: VidsrctoUrl + ) + + data class VidsrctoUrl(@JsonProperty("url") val encUrl: String) +} diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt similarity index 98% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt index 2439b8ad..1161ff66 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoSeyredExtractor.kt @@ -2,7 +2,7 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.* import com.lagradost.cloudstream3.utils.* import com.fasterxml.jackson.annotation.JsonProperty diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VideoVard.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoVard.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VideoVard.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VideoVard.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vidguard.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidguard.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vidguard.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidguard.kt index 230a9e1a..c48b683c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vidguard.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidguard.kt @@ -1,6 +1,6 @@ package com.lagradost.cloudstream3.extractors -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.utils.AppUtils @@ -87,7 +87,7 @@ open class Vidguardto : ExtractorApi() { } Log.d("runJS", "Result: $result") } catch (e: Exception) { - Log.e("runJS", "Error executing JavaScript", e) + Log.e("runJS", "Error executing JavaScript: ${e.message}") } finally { Context.exit() } diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/VidhideExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidhideExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/VidhideExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/VidhideExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vidmoly.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidmoly.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vidmoly.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidmoly.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vido.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vido.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vido.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vido.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vidplay.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidplay.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vidplay.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidplay.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vidstream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidstream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vidstream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vidstream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Voe.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Voe.kt similarity index 93% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Voe.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Voe.kt index 67fd7eea..1d7dee7c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/Voe.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Voe.kt @@ -1,9 +1,9 @@ package com.lagradost.cloudstream3.extractors -import android.util.Base64 import com.fasterxml.jackson.annotation.JsonProperty import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.app +import com.lagradost.cloudstream3.base64Decode import com.lagradost.cloudstream3.utils.AppUtils import com.lagradost.cloudstream3.utils.ExtractorApi import com.lagradost.cloudstream3.utils.ExtractorLink @@ -58,12 +58,12 @@ open class Voe : ExtractorApi() { videoLinks.add( when { linkRegex.matches(link) -> link - else -> String(Base64.decode(link, Base64.DEFAULT)) + else -> base64Decode(link) } ) } else { val link2 = base64Regex.find(script)?.value ?: return - val decoded = Base64.decode(link2, Base64.DEFAULT).toString() + val decoded = base64Decode(link2) val videoLinkDTO = AppUtils.parseJson(decoded) videoLinkDTO.let { videoLinks.add(it.toString()) } } diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Vtbe.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vtbe.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Vtbe.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Vtbe.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/WatchSB.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/WatchSB.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/WatchSB.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/WatchSB.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/WcoStream.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/WcoStream.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/WcoStream.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/WcoStream.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Wibufile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Wibufile.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Wibufile.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Wibufile.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/XStreamCdn.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/XStreamCdn.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/XStreamCdn.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/YourUpload.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/YourUpload.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YourUpload.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/YoutubeExtractor.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YoutubeExtractor.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/YoutubeExtractor.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/YoutubeExtractor.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Zorofile.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Zorofile.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Zorofile.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Zorofile.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/Zplayer.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Zplayer.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/Zplayer.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/Zplayer.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AesHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/AesHelper.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AesHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/AesHelper.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt index 0b401c06..bd42424f 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/AsianEmbedHelper.kt @@ -1,6 +1,6 @@ package com.lagradost.cloudstream3.extractors.helper -import android.util.Log +import com.lagradost.api.Log import com.lagradost.cloudstream3.SubtitleFile import com.lagradost.cloudstream3.amap import com.lagradost.cloudstream3.app diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/GogoHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/GogoHelper.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/GogoHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/GogoHelper.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/NineAnimeHelper.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/VstreamhubHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/VstreamhubHelper.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/VstreamhubHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/VstreamhubHelper.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt similarity index 76% rename from app/src/main/java/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt index 768fa1f6..35aec2b1 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/extractors/helper/WcoHelper.kt @@ -1,8 +1,6 @@ package com.lagradost.cloudstream3.extractors.helper import com.fasterxml.jackson.annotation.JsonProperty -import com.lagradost.cloudstream3.AcraApplication.Companion.getKey -import com.lagradost.cloudstream3.AcraApplication.Companion.setKey import com.lagradost.cloudstream3.app class WcoHelper { @@ -30,9 +28,7 @@ class WcoHelper { private suspend fun getKeys() { keys = keys ?: app.get("https://raw.githubusercontent.com/reduplicated/Cloudstream/master/docs/keys.json") - .parsedSafe()?.also { setKey(BACKUP_KEY_DATA, it) } ?: getKey( - BACKUP_KEY_DATA - ) + .parsedSafe() } suspend fun getWcoKey(): ExternalKeys? { @@ -43,9 +39,7 @@ class WcoHelper { private suspend fun getNewKeys() { newKeys = newKeys ?: app.get("https://raw.githubusercontent.com/chekaslowakiya/BruhFlow/main/keys.json") - .parsedSafe()?.also { setKey(BACKUP_KEY_DATA, it) } ?: getKey( - BACKUP_KEY_DATA - ) + .parsedSafe() } suspend fun getNewWcoKey(): NewExternalKeys? { diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.kt new file mode 100644 index 00000000..8baf2f31 --- /dev/null +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.kt @@ -0,0 +1,28 @@ +package com.lagradost.cloudstream3.network + +import com.lagradost.cloudstream3.USER_AGENT +import okhttp3.Interceptor + +/** + * When used as Interceptor additionalUrls cannot be returned, use WebViewResolver(...).resolveUsingWebView(...) + * @param interceptUrl will stop the WebView when reaching this url. + * @param additionalUrls this will make resolveUsingWebView also return all other requests matching the list of Regex. + * @param userAgent if null then will use the default user agent + * @param useOkhttp will try to use the okhttp client as much as possible, but this might cause some requests to fail. Disable for cloudflare. + * @param script pass custom js to execute + * @param scriptCallback will be called with the result from custom js + * @param timeout close webview after timeout + * */ +expect class WebViewResolver( + interceptUrl: Regex, + additionalUrls: List = emptyList(), + userAgent: String? = USER_AGENT, + useOkhttp: Boolean = true, + script: String? = null, + scriptCallback: ((String) -> Unit)? = null, + timeout: Long = DEFAULT_TIMEOUT +) : Interceptor { + companion object { + val DEFAULT_TIMEOUT: Long + } +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt new file mode 100644 index 00000000..676ac6fe --- /dev/null +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/syncproviders/SyncAPI.kt @@ -0,0 +1,10 @@ +package com.lagradost.cloudstream3.syncproviders + +enum class SyncIdName { + Anilist, + MyAnimeList, + Trakt, + Imdb, + Simkl, + LocalList, +} diff --git a/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt new file mode 100644 index 00000000..374751a8 --- /dev/null +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/AppUtils.kt @@ -0,0 +1,24 @@ +package com.lagradost.cloudstream3.utils + +import com.fasterxml.jackson.module.kotlin.readValue +import com.lagradost.cloudstream3.mapper + +object AppUtils { + /** Any object as json string */ + fun Any.toJson(): String { + if (this is String) return this + return mapper.writeValueAsString(this) + } + + inline fun parseJson(value: String): T { + return mapper.readValue(value) + } + + inline fun tryParseJson(value: String?): T? { + return try { + parseJson(value ?: return null) + } catch (_: Exception) { + null + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt similarity index 97% rename from app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt index ce6e5ecc..566e29f0 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/ExtractorApi.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/ExtractorApi.kt @@ -1,9 +1,8 @@ package com.lagradost.cloudstream3.utils -import android.net.Uri import com.fasterxml.jackson.annotation.JsonIgnore +import com.lagradost.cloudstream3.IDownloadableMinimum import com.lagradost.cloudstream3.SubtitleFile -import com.lagradost.cloudstream3.TvType import com.lagradost.cloudstream3.USER_AGENT import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.extractors.AStreamHub @@ -431,7 +430,7 @@ open class ExtractorLink constructor( /** Used for getExtractorVerifierJob() */ open val extractorData: String? = null, open val type: ExtractorLinkType, -) : VideoDownloadManager.IDownloadableMinimum { +) : IDownloadableMinimum { val isM3u8: Boolean get() = type == ExtractorLinkType.M3U8 val isDash: Boolean get() = type == ExtractorLinkType.DASH @@ -530,29 +529,6 @@ open class ExtractorLink constructor( } } -data class ExtractorUri( - val uri: Uri, - val name: String, - - val basePath: String? = null, - val relativePath: String? = null, - val displayName: String? = null, - - val id: Int? = null, - val parentId: Int? = null, - val episode: Int? = null, - val season: Int? = null, - val headerName: String? = null, - val tvType: TvType? = null, -) - -data class ExtractorSubtitleLink( - val name: String, - override val url: String, - override val referer: String, - override val headers: Map = mapOf() -) : VideoDownloadManager.IDownloadableMinimum - /** * Removes https:// and www. * To match urls regardless of schema, perhaps Uri() can be used? diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/M3u8Helper.kt similarity index 100% rename from app/src/main/java/com/lagradost/cloudstream3/utils/M3u8Helper.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/M3u8Helper.kt diff --git a/app/src/main/java/com/lagradost/cloudstream3/utils/UnshortenUrl.kt b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/UnshortenUrl.kt similarity index 96% rename from app/src/main/java/com/lagradost/cloudstream3/utils/UnshortenUrl.kt rename to library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/UnshortenUrl.kt index 46b232f6..b13e88e5 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/utils/UnshortenUrl.kt +++ b/library/src/commonMain/kotlin/com/lagradost/cloudstream3/utils/UnshortenUrl.kt @@ -1,6 +1,5 @@ package com.lagradost.cloudstream3.utils -import android.util.Base64 import com.lagradost.cloudstream3.app import com.lagradost.cloudstream3.base64Decode import com.lagradost.nicehttp.NiceResponse @@ -91,13 +90,12 @@ object ShortLink { } val encodedbytearray = encodedUri.map { it.code.toByte() }.toByteArray() var decodedUri = - Base64.decode(encodedbytearray, Base64.DEFAULT).decodeToString().dropLast(16) + base64Decode(encodedbytearray.toString()).dropLast(16) .drop(16) if (Regex("""go\.php\?u=""").find(decodedUri) != null) { decodedUri = - Base64.decode(decodedUri.replace(Regex("""(.*?)u="""), ""), Base64.DEFAULT) - .decodeToString() + base64Decode(decodedUri.replace(Regex("""(.*?)u="""), "")) } return decodedUri diff --git a/library/src/jvmMain/kotlin/com/lagradost/api/ContextHelper.jvm.kt b/library/src/jvmMain/kotlin/com/lagradost/api/ContextHelper.jvm.kt new file mode 100644 index 00000000..a30810b8 --- /dev/null +++ b/library/src/jvmMain/kotlin/com/lagradost/api/ContextHelper.jvm.kt @@ -0,0 +1,10 @@ +package com.lagradost.api + +import java.lang.ref.WeakReference + +actual fun getContext(): Any? { + return null +} + +actual fun setContext(context: WeakReference) { +} \ No newline at end of file diff --git a/library/src/jvmMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.jvm.kt b/library/src/jvmMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.jvm.kt new file mode 100644 index 00000000..6b99ef3b --- /dev/null +++ b/library/src/jvmMain/kotlin/com/lagradost/cloudstream3/network/WebViewResolver.jvm.kt @@ -0,0 +1,35 @@ +package com.lagradost.cloudstream3.network + +import okhttp3.Interceptor +import okhttp3.Response + +/** + * When used as Interceptor additionalUrls cannot be returned, use WebViewResolver(...).resolveUsingWebView(...) + * @param interceptUrl will stop the WebView when reaching this url. + * @param additionalUrls this will make resolveUsingWebView also return all other requests matching the list of Regex. + * @param userAgent if null then will use the default user agent + * @param useOkhttp will try to use the okhttp client as much as possible, but this might cause some requests to fail. Disable for cloudflare. + * @param script pass custom js to execute + * @param scriptCallback will be called with the result from custom js + * @param timeout close webview after timeout + * */ +actual class WebViewResolver actual constructor( + interceptUrl: Regex, + additionalUrls: List, + userAgent: String?, + useOkhttp: Boolean, + script: String?, + scriptCallback: ((String) -> Unit)?, + timeout: Long +) : + Interceptor { + + override fun intercept(chain: Interceptor.Chain): Response { + val request = chain.request() + return chain.proceed(request) + } + + actual companion object { + actual val DEFAULT_TIMEOUT = 60_000L + } +}