Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
Bump build number
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperMarcus committed Jul 15, 2023
1 parent 7d68373 commit ee624c3
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ extension NASourceGogoAnime {
}

func anime(url: URL) -> NineAnimatorPromise<Anime> {
self.requestManager
.request(url: url, handling: .browsing)
.responseString
.thenPromise { content -> NineAnimatorPromise<(String, String)> in
self.requestDescriptor()
.thenPromise {
_ in self.requestManager
.request(url: url, handling: .browsing)
.responseString
} .thenPromise { content -> NineAnimatorPromise<(String, String)> in
guard let animeIdentifier = try? SwiftSoup.parse(content)
.select("input#movie_id.movie_id")
.attr("value") else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ extension NASourceGogoAnime {
return
}
_lastRequest = _parent
.requestManager
.request(url: url, handling: .browsing)
.responseString
.then {
.requestDescriptor()
.thenPromise {
[weak self] _ in self?._parent
.requestManager
.request(url: url, handling: .browsing)
.responseString
} .then {
[weak self] content -> [AnimeLink]? in
guard let self = self else { return nil }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ extension NASourceGogoAnime {

/// Retrieve the episode information struct for the episode at the particular path
func episodeInformation(for episodePath: String) -> NineAnimatorPromise<NAGogoAnimeEpisodeInformation> {
requestManager.request(episodePath, handling: .browsing)
.responseString
.then { content in
self.requestDescriptor()
.thenPromise {
[weak self] _ in self?.requestManager.request(episodePath, handling: .browsing)
.responseString
} .then { content in
let bowl = try SwiftSoup.parse(content)

// Parse the streaming sources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ extension NASourceGogoAnime {
try! NSRegularExpression(pattern: "\\/(.+)-episode-\\d+$", options: .caseInsensitive)

func featured() -> NineAnimatorPromise<FeaturedContainer> {
NineAnimatorPromise<[AnimeLink]>.queue(listOfPromises: [
popularAnimeUpdates, latestAnimeUpdates
]) .then { results in BasicFeaturedContainer(featured: results[0], latest: results[1]) }
self.requestDescriptor()
.thenPromise {
[weak self] _ -> NineAnimatorPromise<[[AnimeLink]]>? in
guard let self else { return nil }
return NineAnimatorPromise<[AnimeLink]>.queue(listOfPromises: [
self.popularAnimeUpdates, self.latestAnimeUpdates
])
} .then { results in BasicFeaturedContainer(featured: results[0], latest: results[1]) }
}

fileprivate var latestAnimeUpdates: NineAnimatorPromise<[AnimeLink]> {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// This file is part of the NineAnimator project.
//
// Copyright © 2018-2023 Marcus Zhou. All rights reserved.
//
// NineAnimator is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// NineAnimator is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with NineAnimator. If not, see <http://www.gnu.org/licenses/>.
//

import Foundation

import Foundation
import JavaScriptCore
import NineAnimatorCommon

extension NASourceGogoAnime {
struct SourceDescriptor: Codable {
var currentHost: String
var currentAjaxEndpoint: String
}

func requestUncachedDescriptor() -> NineAnimatorPromise<SourceDescriptor> {
NineAnimator.default.cloud.requestSourceDescriptor(
source: self,
descriptorType: SourceDescriptor.self
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,19 @@ class NASourceGogoAnime: BaseSource, Source, PromiseSource {
\.english
}

override var endpoint: String { "https://gogoanime.vet" }
override var endpoint: String { self._cachedDescriptor?.currentHost ?? "https://gogoanime.vet" }

let ajaxEndpoint = URL(string: "https://ajax.apimovie.xyz")!
var ajaxEndpoint: URL {
var dynamicEndpoint: URL?

if let ajaxEndpointStr = self._cachedDescriptor?.currentAjaxEndpoint {
dynamicEndpoint = URL(string: ajaxEndpointStr)
}

return dynamicEndpoint ?? URL(string: "https://ajax.apimovie.xyz")!
}

private var _cachedDescriptor: SourceDescriptor?

func search(keyword: String) -> ContentProvider {
GogoContentProvider(query: keyword, parent: self)
Expand All @@ -61,4 +71,17 @@ class NASourceGogoAnime: BaseSource, Source, PromiseSource {
override required init(with parent: NineAnimator) {
super.init(with: parent)
}

/// Request the source descriptor object
func requestDescriptor() -> NineAnimatorPromise<SourceDescriptor> {
// Serve cached descriptor is possible
if let cached = self._cachedDescriptor {
return .success(cached)
}

return requestUncachedDescriptor().then {
self._cachedDescriptor = $0
return $0
}
}
}
4 changes: 2 additions & 2 deletions NineAnimator.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2086,7 +2086,7 @@
CODE_SIGN_ENTITLEMENTS = NineAnimator/NineAnimator.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 8WB2V923XT;
ENABLE_BITCODE = NO;
Expand Down Expand Up @@ -2119,7 +2119,7 @@
CODE_SIGN_ENTITLEMENTS = NineAnimator/NineAnimator.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 4;
CURRENT_PROJECT_VERSION = 5;
DERIVE_MACCATALYST_PRODUCT_BUNDLE_IDENTIFIER = YES;
DEVELOPMENT_TEAM = 8WB2V923XT;
ENABLE_BITCODE = NO;
Expand Down

0 comments on commit ee624c3

Please sign in to comment.