gkye / themoviedatabaseswiftwrapper Goto Github PK
View Code? Open in Web Editor NEWSwift wrapper for themoviedb.org api v3
License: MIT License
Swift wrapper for themoviedb.org api v3
License: MIT License
There is currently no wrapper for the /trending api.
https://developers.themoviedb.org/3/trending/get-trending
Hi,
Entrypoint for image and video's movie are not yet implemented. Can you make public the method final func networkRequest(url url: String, parameters: [String : AnyObject], completion: (ClientReturn) -> ()) -> ()
I see that there is a Client authentication file, however I can't seem to be able to locate them. How do you call these methods?
Since Xcode can now (as of Xcode 11 beta) handle Swift Package Manager dependencies, could you please add support, so that your library can be fetched by the Swift PM insted of using CocoaPods?
Hello,
Is there a way to retrieve the image dat? I now I can retrieve the filename (e.g. /rRgkZUNgD68DD7xDsv1XMmQBjld.jpg
), but there is no clear way to retrieve the actual image. If it's up to client to retrieve it, how is the URL constructed? Let's assume https://api.themoviedb.org/3/person/1042728
:
{
"aspect_ratio": 0.66666666666667,
"file_path": "/uSSUrSdzH73bcy5hWIB5SZFzuFm.jpg",
"height": 705,
"iso_639_1": null,
"vote_average": 5.312,
"vote_count": 1,
"width": 470
}
These URLs return an error: ๐ค
https://api.themoviedb.org/3/person/1042728/uSSUrSdzH73bcy5hWIB5SZFzuFm.jpg https://api.themoviedb.org/3/person/1042728/images/uSSUrSdzH73bcy5hWIB5SZFzuFm.jpg
@gkye @djpearce
Sorry to bother you.
I'm not sure I understand the data structure for these nested types correctly, but imdb_id
(and others) seem to not be decoding correctly.
First of all, it's a string in json and the prop is Int!
I augmented tests below to confirm. Let me open a PR soon.
TheMovieDatabaseSwiftWrapper/Tests/TMDBSwiftTests/MovieMDBTests.swift
Lines 34 to 46 in 094a8d9
func testMovieById() {
var data: MovieDetailedMDB?
let expectation = self.expectation(description: "Wait for data to load.")
MovieMDB.movie(movieID: 7984) { ddd, movie in
debugPrint(String(data: ddd.data!, encoding: .utf8))
data = movie
expectation.fulfill()
}
waitForExpectations(timeout: expectationTimeout, handler: nil)
XCTAssertNotNil(data)
XCTAssertEqual(data?.title, "In the Name of the Father")
XCTAssertEqual(data?.imdb_id, "tt0107207") // fails `nil`
XCTAssertEqual(data?.homepage, "") // fails `nil`
XCTAssertEqual(data?.runtime, 133) // fails `nil`
}
func testMovieDetailById() {
var data: MovieDetailedMDB?
let expectation = self.expectation(description: "Wait for data to load.")
MovieDetailedMDB.movie(movieID: 7984) { ddd, movie in
debugPrint(String(data: ddd.data!, encoding: .utf8))
data = movie
expectation.fulfill()
}
waitForExpectations(timeout: expectationTimeout, handler: nil)
XCTAssertNotNil(data)
XCTAssertEqual(data?.title, "In the Name of the Father")
XCTAssertEqual(data?.imdb_id, "tt0107207") // fails `nil`
XCTAssertEqual(data?.homepage, "") // fails `nil`
XCTAssertEqual(data?.runtime, 133) // fails `nil`
}
HI,
I cloned the Repo using the Github desktop client. Am trying to run/build the project. Every time i do this am getting the success message, but the application is not running on any devices. Its displaying "Build Succeeded"
Am using Xcode 9.4.1
The application crashes when an empty list is returned. I attach screenshots from Crashlytics.
In the FindMDB.swift
file on line 123
:
data = FindMDB.init(json: apiReturn.json!)
<- force unwrapping
Screen:
In the MovieMDB.swift
file on line 27
:
detailed = MovieDetailedMDB.init(results: apiReturn.json!)
<- force unwrapping
Screen:
Also in this file all methods have force unwrapping.
Thank you for your work.
I can't run pod trunk push TMDBSwift.podspec
myself because my email isn't added as an owner of the repo. @gkye Could you help me get added to the owners group of the podspec, or push the update yourself.
Adding other people as contributors
The first person to push a Podspec version to Trunk can add other maintainers. For example, to add [email protected] to the library ARAnalytics:
$ pod trunk add-owner ARAnalytics [email protected]
This will then list all the known library owners. Note: they need to already have registered an account set up on trunk in order for you to add them to a library.
From what I can tell the demo app submodule was removed or at least the path was broken in some way.
Are we safe to remove reference to it for the time being until a potentially new demo app is constructed?
hi,
first thank you for your job and i have a request about the api.
api don't return movie genre. can you fix this please?
thank you
Hi!
First of all, thank you for the library!
(Actually this is not an issue, it's a question or even a help request.)
Recently I updated my pods and I saw that you released a new version (congratulations!). I noticed in your commits that you removed api key parameters, but there's a great lack of documentation. How can we use it now?
I guess there's some kind of preparatory function but how can I find it?
I used to just call ConfigurationMDB.configuration, TVMDB.popular and SearchMDB.tv. That's it. And all this worked for me.
Thanks in advance for your reply!
The code I tried is taken from the wiki:
MovieMDB.movie(apikey, movieID: 7984, language: "en"){
apiReturn, movie in
if let movie = movie{
print(movie.title)
print(movie.revenue)
print(movie.genres[0].name)
print(movie.production_companies?[0].name)
}
}
production_companies
, production_countries
appear in apiReturn
, but
print(movie.production_companies?[0].name)
return nil
A few of the endpoints such as:
https://developers.themoviedb.org/3/tv/get-tv-details
Has append to response functionality, it's benefits are outlined here: https://developers.themoviedb.org/3/getting-started/append-to-response
The function below worked perfectly fine in swift2 but since updating to swift3 initializing no longer takes place and the for-loop is skipped after the first attempt. I've set multitudes of break points but still can't understand why this happens
//MARK: Array protocol returns an array of types by initlizaing using the json passed
public protocol ArrayObject {
init(results: JSON)
}
extension ArrayObject {
public static func initialize<T:ArrayObject>(json: JSON) -> [T] {
var array = [T]()
//For loop bails after the first attempt **
for i in 0..<json.count{
array.append(T.init(results: json[i]))
}
return array
}
}
It looks like there was a typo when adding the 5.0.1 tag since it goes so far out of the semantic versioning iteration. Could this be deleted for consistency?
hi,
the upcoming function doesn't accept page parameter. Can you fix it please?
With the migration to codable mostly done, I think it's worth asking if we could talk about bumping the minimum targets to the iOS 14 era of versions. This opens up the door for maybe using Async/Await and reintroducing a demo project in SwiftUI amongst other changes.
Curious on others thoughts on the matter!
Based on my setup for GitHub Pages seen here: https://github.com/djpearce/TheMovieDatabaseSwiftWrapper
at this URL: https://djpearce.github.io/TheMovieDatabaseSwiftWrapper/documentation/tmdbswift
I think the settings of this repo need updated, here's the settings on my repo:
cc: @gkye
Request:
MovieMDB.movie(movieID: tmdbID) { (value, find) in
print(find?.belongs_to_collection?.backdrop_path as Any)
print(find?.belongs_to_collection?.poster_path as Any)
print(value.json?["poster_path"] as Any)
print(value.json?["backdrop_path"] as Any)
print("https://image.tmdb.org/t/p/w500/\(value.json?["poster_path"])")
print("https://image.tmdb.org/t/p/w500/\(value.json?["backdrop_path"])")
}
ConsoleOutput:
nil
nil
Optional(/j4CBsXaGcltcHGbcxsWD5VfEaiU.jpg)
Optional(/i26FIo5vJrR4u8ZZBm8o5Q4T9di.jpg)
https://image.tmdb.org/t/p/w500/Optional(/j4CBsXaGcltcHGbcxsWD5VfEaiU.jpg)
https://image.tmdb.org/t/p/w500/Optional(/i26FIo5vJrR4u8ZZBm8o5Q4T9di.jpg)
It seems that the https://api.themoviedb.org is not reachable any longer.
iOS SDK throws the -1003 error with the A server with the specified hostname could not be found
description.
The https://www.themoviedb.org site also cannot be reached, so it seems something has happened to it.
If TMDB returns a page with error 502, the application crashes, so it tries to parse the answer.
The crash occurs in the Client.swift
in line 42
let json = try! JSON(data: data!)
Error:
Thread 1: Fatal error: 'try!' expression unexpectedly raised an error: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
po response.debugDescription
:
"Optional(<NSHTTPURLResponse: 0x1c483e8a0> { URL: https://api.themoviedb.org/3/find/tt0258000?api_key=mykey&external_source=imdb_id } { Status Code: 502, Headers {\n Connection = (\n \"keep-alive\"\n );\n \"Content-Length\" = (\n 166\n );\n \"Content-Type\" = (\n \"text/html\"\n );\n Date = (\n \"Sat, 17 Feb 2018 23:00:13 GMT\"\n );\n Server = (\n openresty\n );\n \"X-RateLimit-Limit\" = (\n 40\n );\n \"X-RateLimit-Remaining\" = (\n 39\n );\n \"X-RateLimit-Reset\" = (\n 1518908423\n );\n} })"
Whenever I am trying to use the discover function:
DiscoverMovieMDB.discoverMovies(apiKey, language: "EN", page: nil, sort_by: DiscoverSortByMovie.primary_release_date_desc) { (returnData, movies) in
}
It tells me that there is an Ambiguous reference to member 'discoverMovies(_:language:page:sort_by:completion:)' I am using the Swift 3 branch.
Am I doing something wrong?
Hi. I know this isn't a technical issue with TMDBSwift, but I just discovered it, and I'm a new developer. Very new. So here's my stupid "issue": I don't even know how to import it into my Xcode project to start using it!
I have searched the web, stack overflow, and just can't see an answer. I feel so stupid, but wanted to reach out to you directly to see if you could give me the probably-super-simple step-by-step instructions. Closest I found is this: http://stackoverflow.com/questions/34099841/import-my-custom-module-framework-xcode-swift - but I have tried adding the .h file via 'settings > embedded binaries' and 'settings > linked frameworks and libraries'... when I try the latter, the TMDBswift.h file appears under 'linked frameworks and libraries' yet every time I try to import TMDBSwift at the top of my ViewController.swift file, xcode complains 'no such module'.
Again, I'm sorry. I'm sure it's simple (when you know) but this is my first time trying to add an external framework to a project. Thanks for any help (and you can delete this 'issue' afterwards)!
"To run the example project, clone the repo, and run pod install from the Demo directory first."
[!] No 'Podfile' found in the project directory.
When using your Wiki code
DiscoverMDB.discover(apiKey, discoverType: "tv", language: nil){
apiReturn in
let tvshows = apiReturn.MBDBReturn as! [TVMDB]
print(tvshows[0].name)
print(tvshows[0].overview)
print(tvshows[0].popularity)
}
I get that ClientReturn has no member MBDBReturn?
Hello,
It looks like there is an issue with the Wiki Documentation, when I updated to the newest version I am getting errors with discoverMovies function, looks like things may have moved to a params argument rather than spelled out like they were. Not sure what the params are supposed to look like for your functions.
Hi, I'm new to the OSS game, but would be interested refactoring SwiftyJSON to Codable.
Are you on that already? If not, I would submit a pull request.
Hi,
I update my project to swift 3 but i encounter some compilation problem with the pod tmdbswift.
Did you update the pod to support swift 3?
HI
I try to add pod 'TMDBSwift' for tv os build on cocoad pod, but iit's not running.
[!] The platform of the target
TiburonVideo_tvOS(tvOS 13.0) is not compatible with
TMDBSwift (0.5.1), which does not support
tvOS.
How can it be solved?
Bests
Alex
Hi,
first of all: thanks for this all!
As a total beginner in both swift and ... eh... this here (;-)) I managed to add everything to an existing project but there were two sections leaving me with error messages from Xcode. One of them was just a usage of outdated code. The warning said:
"characters is deprecated". So I changed it:
old:
text.characters.count
new:
text.count
I'm having a real pain with the other issue. It's in the file Client.swift
There's the following block:
struct Client{
static func networkRequest(url: String, parameters: [String : AnyObject], completion: @escaping (ClientReturn) -> ()) -> (){
var cReturn = ClientReturn()
HTTPRequest.request(url, parameters: parameters){
rtn in // <- here's the error!
if rtn.2 == nil{
let json = try! JSON(data: rtn.0!)
cReturn.error = nil
cReturn.json = json
if(json["page"].exists()){
cReturn.pageResults = PageResultsMDB.init(results: json)
}else{
cReturn.pageResults = nil
}
}else{
cReturn.error = rtn.2 as NSError?
cReturn.json = nil
cReturn.pageResults = nil
}
completion(cReturn)
}
where it says "rtn in" there's an error message saying:
"Contextual closure type '(Data?, URLResponse?, Error?) -> ()' expects 3 arguments, but 1 was used in closure body".
It advises:
"Insert ',<#arg#>,<#arg#> '"
Can anyone tell me what to do here? I've never heard of that. I searched the web for this but I just don't get the cases described there.
Thanks in advance and have a great week
Patrick
P.S.: I'm totally new to GitHub but I thought this might be the right place to ask this. If not, please don't be angry :-/
v3 of the API seems mostly stable at this time and v4 has been started in some capacity. Our unit tests currently are really integration tests that run directly off the API. While this type of testing is good to have it shouldn't be our main source for unit tests. I think we should look to enhance our unit test suite with mock data and focus more on testing the parameters, the creation of the network request, and the decode-ability of individual models.
We can then look to have suites of tests run specifically on pull requests and pushes to master or on a cron job to continue to test the validity of the APIs contracts less frequently and away from PRs.
While it may not matter for the frequency of contribution to this repo, I think it's good to stay towards leading standards either way.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.