From ddf10ed137aeef083726f2c2ba7a16e4c694313d Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 21 Jan 2017 19:15:06 -0500 Subject: [PATCH] Added couchpotato, and added a test --- .../Files/couchpotato_movie_list.json | 449 ++++++++++++++++++ .../CouchPotato/CouchPotatoParserFixture.cs | 37 ++ .../NzbDrone.Core.Test.csproj | 4 + .../NetImport/CouchPotato/CouchPotatoAPI.cs | 157 +++--- .../CouchPotato/CouchPotatoParser.cs | 106 +++++ .../CouchPotatoRequestGenerator.cs | 28 ++ .../CouchPotato/CouchPotatoSettings.cs | 26 + .../NetImport/RSSImport/IMDbWatchListAPI.cs | 40 -- .../NetImport/RSSImport/IMDbWatchListProxy.cs | 79 --- .../RSSImport/RSSImportRequestGenerator.cs | 8 +- .../NetImport/RSSImport/RSSImportSettings.cs | 1 - src/NzbDrone.Core/NzbDrone.Core.csproj | 10 +- 12 files changed, 736 insertions(+), 209 deletions(-) create mode 100644 src/NzbDrone.Core.Test/Files/couchpotato_movie_list.json create mode 100644 src/NzbDrone.Core.Test/NetImport/CouchPotato/CouchPotatoParserFixture.cs create mode 100644 src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs create mode 100644 src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoRequestGenerator.cs create mode 100644 src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoSettings.cs delete mode 100644 src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListAPI.cs delete mode 100644 src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListProxy.cs diff --git a/src/NzbDrone.Core.Test/Files/couchpotato_movie_list.json b/src/NzbDrone.Core.Test/Files/couchpotato_movie_list.json new file mode 100644 index 000000000..ba027936b --- /dev/null +++ b/src/NzbDrone.Core.Test/Files/couchpotato_movie_list.json @@ -0,0 +1,449 @@ +{ + "movies": [ + { + "status": "active", + "info": { + "rating": { "imdb": [ 8.1, 228515 ] }, + "genres": [ "Action", "Adventure", "Fantasy", "Science Fiction", "Thriller", "War", "Sci-Fi" ], + "tmdb_id": 330459, + "plot": "A rogue band of resistance fighters unite for a mission to steal the Death Star plans and bring a new hope to the galaxy.", + "tagline": "A Rebellion Built on Hope", + "release_date": { + "dvd": 1461016800, + "expires": 1486410729, + "theater": 1453417200, + "bluray": true + }, + "year": 2016, + "original_title": "Rogue One: A Star Wars Story", + "actor_roles": { + "Warwick Davis": "Bistan", + "Michael Giacchino": "Stormtrooper", + "Lex Lang": "Stormtrooper", + "Samuel Witwer": "Stormtrooper", + "Steen Young": "Vault Officer", + "Russell Balogh": "X-Wing Pilot", + "Alan Tudyk": "K-2SO", + "Angus Cook": "Mechanic", + "David Boat": "Stormtrooper", + "Kevin Hickman": "Stormtrooper", + "Aidan Cook": "Edrio Two Tubes", + "Valene Kane": "Lyra Erso", + "Simon Farnaby": "Blue Squadron", + "Donnie Yen": "Chirrut Imwe", + "Forest Whitaker": "Saw Gerrera", + "Jordan Stephens": "Corporal Tonc", + "Verona Blue": "Stormtrooper", + "David Sobolov": "Stormtrooper", + "Attila G. Kerekes": "Rebel Marine on Yavin", + "Ian McElhinney": "General Dodonna", + "John Gilroy": "Stormtrooper", + "Matthew Wood": "Stormtrooper", + "Jiang Wen": "Baze Malbus", + "Sharon Duncan-Brewster": "Senator Pamlo", + "Christopher Scarabosio": "Stormtrooper", + "Stephen Stanton": "Admiral Raddus (voice)", + "Andrew Zographos": "X-Wing Pilot", + "Ben Daniels": "General Merrick", + "James Arnold Taylor": "Stormtrooper", + "Robin Atkin Downes": "Stormtrooper", + "Guy Henry": "Grand Moff Tarkin", + "Mac Pietowski": "Commi Tech / Marine Soldier", + "James Earl Jones": "Darth Vader (voice)", + "Daniel Naprous": "Darth Vader", + "Geraldine James": "Blue Squadron", + "Eugene Byrd": "Stormtrooper", + "Michael Donovan": "Stormtrooper", + "Paul Kasey": "Admiral Raddus", + "Fred Tatasciore": "Stormtrooper", + "Vanessa Lengies": "Stormtrooper", + "Duncan Pow": "Sergeant Melshi", + "Dolly Gadsdon": "Younger Jyn (as Dolly Gadson)", + "David Acord": "Stormtrooper", + "Nick Kellington": "Bistan", + "Julian Stone": "Stormtrooper", + "Christian Simpson": "Stormtrooper", + "Alistair Petrie": "General Draven", + "Ariyon Bakare": "Blue Squadron", + "Drewe Henley": "Red Leader Garven Dreis", + "Ram Bergman": "Death Star technician", + "Anthony Daniels": "C-3PO", + "Derek Arnold": "Pao", + "Karen Huie": "Stormtrooper", + "Steve Bardrack": "Stormtrooper", + "Jonathan Aris": "Senator Jebel", + "Alexi Melvin": "Stormtroooper", + "Emeson Nwolie": "Personnel", + "Tyrone Love": "Rebel Marine Commander", + "John S. Schwartz": "Stormtrooper", + "Orly Schuchmacher": "Stormtrooper", + "Dave Filoni": "Stormtrooper", + "Yuri Lowenthal": "Stormtrooper", + "Mads Mikkelsen": "Galen Erso", + "Fares Fares": "Senator Vaspar", + "Ian Whyte": "Moroff", + "Genevieve O'Reilly": "Mon Mothma", + "Jorge Leon Martinez": "X-Wing Pilot", + "Beau Gadsdon": "Young Jyn", + "Katie Sheridan": "Stormtrooper", + "Michael Smiley": "Dr. Evazan", + "Babou Ceesay": "Lieutenant Sefla", + "Tom Harrison-Read": "Stormtrooper", + "Spencer Wilding": "Darth Vader", + "Tom Kane": "Stormtrooper", + "Riz Ahmed": "Bodhi Rook", + "Ingvild Deila": "Princess Leia", + "Tony Gilroy": "Stormtrooper", + "Felicity Jones": "Jyn Erso", + "Jonathan Dixon": "Stormtrooper", + "Angus MacInnes": "Gold Leader Dutch Vander", + "William M. Patrick": "Stormtroooper", + "Diego Luna": "Captain Cassian Andor", + "Sam Hanover": "Imperial Officer", + "Jimmy Smits": "Bail Organa", + "Ned Dennehy": "Prisoner", + "Rian Johnson": "Death Star Technician", + "Jimmy Vee": "R2-D2", + "David Cowgill": "Stormtrooper", + "Vanessa Marshall": "Stormtrooper", + "Terri Douglas": "Stormtrooper", + "David Ankrum": "Wedge Antilles", + "Flora Miller": "Stormtroooper", + "Steve Blum": "Stormtrooper", + "Ben Mendelsohn": "Director Orson Krennic" + }, + "via_imdb": true, + "images": { + "disc_art": [], + "poster": [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMjEwMzMxODIzOV5BMl5BanBnXkFtZTgwNzg3OTAzMDI@._V1_SX300.jpg" ], + "backdrop": [ "https://image.tmdb.org/t/p/w1280/tZjVVIYXACV4IIIhXeIM59ytqwS.jpg" ], + "extra_thumbs": [], + "poster_original": [ "https://image.tmdb.org/t/p/original/qjiskwlV1qQzRCjpV0cL9pEMF9a.jpg" ], + "actors": { + "Warwick Davis": "https://image.tmdb.org/t/p/w185/5xBunTQJexQOuCmtlh8MNJerbaM.jpg", + "Michael Giacchino": "https://image.tmdb.org/t/p/w185/2YW8sSVvRhCwiQmsFCgtFsGkbv8.jpg", + "Michael Smiley": "https://image.tmdb.org/t/p/w185/muzJQpsKJ4srfVpyRa7qkrRYWSq.jpg", + "Babou Ceesay": "https://image.tmdb.org/t/p/w185/7HtIvbNxACa03ofJpN4EFQTNtRU.jpg", + "Julian Stone": "https://image.tmdb.org/t/p/w185/sNKqRYXFYHCz8lXExXl0DAl3iGD.jpg", + "Jordan Stephens": "https://image.tmdb.org/t/p/w185/oCQl5rkRExrDhGXNPeSxsmC5wvk.jpg", + "Alistair Petrie": "https://image.tmdb.org/t/p/w185/tC5CHVPnxAMqF0W0csTqcDAawwj.jpg", + "Samuel Witwer": "https://image.tmdb.org/t/p/w185/e4FRojd6SmiyRLo2nQQGUXwi16v.jpg", + "Ben Daniels": "https://image.tmdb.org/t/p/w185/x6MI4Fdz1XbERbNbXYoxTK6NAgv.jpg", + "Ariyon Bakare": "https://image.tmdb.org/t/p/w185/xjJlH9hU58Ocy6GxKfBlEvTif1p.jpg", + "James Arnold Taylor": "https://image.tmdb.org/t/p/w185/rAtyfY0diWt078qQIg0IX9xxG9F.jpg", + "Robin Atkin Downes": "https://image.tmdb.org/t/p/w185/pCnIQMMgrFc4hBOE4LJDdebqRZ4.jpg", + "Drewe Henley": "https://image.tmdb.org/t/p/w185/C28FmnpDyhI9BwD6YjagAe1U53.jpg", + "Spencer Wilding": "https://image.tmdb.org/t/p/w185/g3FJIpQZri7gG515rLehuo81T6W.jpg", + "Alan Tudyk": "https://image.tmdb.org/t/p/w185/6QuMtbD8kmhpwWhFKfNzEvHRLOu.jpg", + "Guy Henry": "https://image.tmdb.org/t/p/w185/zNjPC6BTZj7DZK4KFL0nMC1El2S.jpg", + "Angus Cook": "https://image.tmdb.org/t/p/w185/jPc794vF0h8bmslQ3sO8O3vUVIa.jpg", + "David Boat": "https://image.tmdb.org/t/p/w185/4ewxttZW0bhlta27oc5Tjrxel3p.jpg", + "Tom Kane": "https://image.tmdb.org/t/p/w185/hAyEHNuhD6PqbPdCNR7iUyM271I.jpg", + "Anthony Daniels": "https://image.tmdb.org/t/p/w185/cljvryjb3VwTsNR7fjQKjNPMaBB.jpg", + "Duncan Pow": "https://image.tmdb.org/t/p/w185/vJOzoMzxszyZGnySfql3KY9zR78.jpg", + "Fares Fares": "https://image.tmdb.org/t/p/w185/1BE5IG3hcFXfMjBuJJyKs2JpPjI.jpg", + "Tony Gilroy": "https://image.tmdb.org/t/p/w185/9HOtDgcO6F4Fa4BaIjt0t3Vbxrj.jpg", + "Felicity Jones": "https://image.tmdb.org/t/p/w185/9YekpRl6ndS7zpY0wwZAWcAXkl8.jpg", + "Eugene Byrd": "https://image.tmdb.org/t/p/w185/ab4zEcqdBSjpaz4CPQ2Z6q4rLmO.jpg", + "Jonathan Aris": "https://image.tmdb.org/t/p/w185/6RMuwGYfLLGq01LNGBydj9jpTWn.jpg", + "Valene Kane": "https://image.tmdb.org/t/p/w185/7TcV6HqGXjf28yjuSU42Z5XZRYb.jpg", + "Angus MacInnes": "https://image.tmdb.org/t/p/w185/qftkol8hj7yBBP3KCxRWYkhRyLC.jpg", + "James Earl Jones": "https://image.tmdb.org/t/p/w185/2ZuBf3ip2RXhkiQqGUjbUzAf4Nx.jpg", + "Emeson Nwolie": "https://image.tmdb.org/t/p/w185/dWCOK3qCOm1Vve567FXKhBp5x8B.jpg", + "Terri Douglas": "https://image.tmdb.org/t/p/w185/lECiABogAKm5Zl8Je6niNAoqz5N.jpg", + "Simon Farnaby": "https://image.tmdb.org/t/p/w185/3u1ObLUvaTyEMmpWQnkRg5Trlng.jpg", + "Donnie Yen": "https://image.tmdb.org/t/p/w185/vlKBbOc0htUsDGvcxeULcFXDMRo.jpg", + "Forest Whitaker": "https://image.tmdb.org/t/p/w185/4pMQkelS5lK661m9Kz3oIxLYiyS.jpg", + "Diego Luna": "https://image.tmdb.org/t/p/w185/9f1y0pLqohP8U3eEVCa4di1tESb.jpg", + "Dave Filoni": "https://image.tmdb.org/t/p/w185/1m7ijGgs29Emn3Sj08c1GwGTUm0.jpg", + "Jimmy Smits": "https://image.tmdb.org/t/p/w185/tZfr6EaIxzlT9MhY5T4C6cL3UjF.jpg", + "Yuri Lowenthal": "https://image.tmdb.org/t/p/w185/d5vbYEkrPYAiVdTee8e4xCm7Fg1.jpg", + "Verona Blue": "https://image.tmdb.org/t/p/w185/9UJiyVd65nGCVLsTuFjtF3ejCqa.jpg", + "David Sobolov": "https://image.tmdb.org/t/p/w185/lUXbnlyQPsfAGg0oinCtj6KlOkt.jpg", + "Ned Dennehy": "https://image.tmdb.org/t/p/w185/k4kgPvUND2eTrgmotrVWVJM0JUG.jpg", + "Ian McElhinney": "https://image.tmdb.org/t/p/w185/33RGircMDTbdvD6LUp8sLmQKWvA.jpg", + "Fred Tatasciore": "https://image.tmdb.org/t/p/w185/lNe4zn9fJ302GehQVaFk5BNcGGM.jpg", + "Mads Mikkelsen": "https://image.tmdb.org/t/p/w185/nJjN0bS6ssbOrXcnPJrNEIsbX9s.jpg", + "Paul Kasey": "https://image.tmdb.org/t/p/w185/56f0ouOg2ASKKKZlaywor8E5V3J.jpg", + "David Cowgill": "https://image.tmdb.org/t/p/w185/kcGjj4EuHfMp0VILRVoacoPqNFL.jpg", + "Ian Whyte": "https://image.tmdb.org/t/p/w185/6mRY7hTtHfDTGuTLmZmODOu9buF.jpg", + "Genevieve O'Reilly": "https://image.tmdb.org/t/p/w185/8NrrFxrGng88GU7lxwOyK3PZv05.jpg", + "Jorge Leon Martinez": "https://image.tmdb.org/t/p/w185/nWYveATaySCXosWAjcSS8VNPRe7.jpg", + "Katie Sheridan": "https://image.tmdb.org/t/p/w185/awNPsff9HU7NgAhG1qQ4Kh7pMmj.jpg", + "Vanessa Marshall": "https://image.tmdb.org/t/p/w185/wOXilt4TVOd0LuTw6RbWhe5DUy4.jpg", + "Vanessa Lengies": "https://image.tmdb.org/t/p/w185/vU4syqfb0PYE9efbBq9YZQu24cY.jpg", + "David Ankrum": "https://image.tmdb.org/t/p/w185/vo6JMA38exMSSbyQ3K0YCBwBrWT.jpg", + "Riz Ahmed": "https://image.tmdb.org/t/p/w185/yWjuIP634unLBCB4XjSgmJs5QGC.jpg", + "Steve Blum": "https://image.tmdb.org/t/p/w185/asCL6bWSZ7Xl2kSoRqrPB0CUUUU.jpg", + "Rian Johnson": "https://image.tmdb.org/t/p/w185/qWWRFkeMjTjQKoyEXhsV0QQp4qd.jpg", + "Matthew Wood": "https://image.tmdb.org/t/p/w185/oB9wVbEIg8fjY3ulDKjKsGn2A55.jpg", + "Jiang Wen": "https://image.tmdb.org/t/p/w185/sLLXxXg11VFdVYFthF9RB8wIQKv.jpg", + "Ben Mendelsohn": "https://image.tmdb.org/t/p/w185/nAeZkSUXh9CUAUq1cFAg77rZLIS.jpg", + "Geraldine James": "https://image.tmdb.org/t/p/w185/iHKFccX2qpSzMbhIBdfvr835MVg.jpg", + "Russell Balogh": "https://image.tmdb.org/t/p/w185/yCfE3Pf1npGB15Rw8GHt4nvgK6p.jpg" + }, + "backdrop_original": [ "https://image.tmdb.org/t/p/original/tZjVVIYXACV4IIIhXeIM59ytqwS.jpg" ], + "clear_art": [], + "logo": [], + "banner": [], + "landscape": [], + "extra_fanart": [] + }, + "directors": [ "Gareth Edwards" ], + "titles": [ "Rogue One: A Star Wars Story", "Rogue One", "Star Wars: Rogue One", "Star Wars Anthology: Rogue One", "Rogue One: Uma História Star Wars", "星際大戰外傳:俠盜一號", "Rogue One - A Star Wars Story", "星球大战外传:侠盗一号", "Rogue One: История от Междузвездни войни", "Star Wars - Rouge One" ], + "imdb": "tt3748528", + "mpaa": "PG-13", + "via_tmdb": true, + "actors": [ "Felicity Jones", "Diego Luna", "Alan Tudyk", "Donnie Yen" ], + "writers": [ "Chris Weitz (screenplay)", "Tony Gilroy (screenplay)", "John Knoll (story by)", "Gary Whitta (story by)", "George Lucas (based on characters created by)" ], + "runtime": 133, + "type": "movie", + "released": "16 Dec 2016" + }, + "_t": "media", + "releases": [], + "title": "Rogue One: A Star Wars Story", + "_rev": "00030f77", + "profile_id": "38699ec285c447bab0bc6267ffb2f3ad", + "_id": "d9d4e0ff9b0842518b9d5f5184a60f31", + "category_id": null, + "type": "movie", + "files": { "image_poster": [ "C:\\Users\\devin\\AppData\\Roaming\\CouchPotato\\cache\\2100049b45a923e858dd161ae28b1f4d.jpg" ] }, + "identifiers": { "imdb": "tt3748528" } + }, + { + "status": "active", + "info": { + "rating": { "imdb": [ 7.3, 16900 ] }, + "genres": [ "Animation", "Comedy", "Family", "Music", "Drama" ], + "tmdb_id": 335797, + "plot": "In a city of humanoid animals, a hustling theater impresario's attempt to save his theater with a singing competition becomes grander than he anticipates even as its finalists' find that their lives will never be the same.", + "tagline": "Auditions begin 2016.", + "release_date": { + "dvd": 1490997600, + "expires": 1485114888, + "theater": 1482274800, + "bluray": true + }, + "year": 2016, + "original_title": "Sing", + "actor_roles": { + "Taron Egerton": "Johnny (voice)", + "Catherine Cavadini": "Additional Voices (voice)", + "Beck Bennett": "Lance (voice)", + "Rhea Perlman": "Judith (voice)", + "Jon Robert Hall": "Frog (voice)", + "Abby Craden": "Additional Voices (voice)", + "Jim Cummings": "Additional Voices (voice)", + "Peter Serafinowicz": "Big Daddy (voice)", + "Bill Farmer": "News Reporter Dog (voice)", + "Jessica Rau": "Additional Voices (voice)", + "Townsend Coleman": "Additional Voices (voice)", + "Jen Faith Brown": "Singer (voice)", + "Brad Morris": "Baboon (voice)", + "Doug Burch": "Additional Voices (voice)", + "Jennifer Hudson": "Young Nana (voice)", + "Laura Dickinson": "Spider (voice)", + "Jeremy Maxwell": "Additional Voices (voice)", + "Asher Blinkoff": "Piglet (voice)", + "Reese Witherspoon": "Rosita (voice)", + "Scarlett Johansson": "Ash (voice)", + "Carlos Alazraqui": "Additional Voices (voice)", + "Edgar Wright": "Additional Voices (voice)", + "Asa Jennings": "Piglet (voice)", + "Nick Offerman": "Norman (voice)", + "Mickael Carreira": "Voice 3", + "Sara Mann": "Additional Voices (voice)", + "Jay Pharoah": "Meena's Grandfather (voice)", + "Adam Buxton": "Stan (voice)", + "Garth Jennings": "Miss Crawly / Additional Voices (voice)", + "Deolinda Kinzimba": "Voice 4", + "Jess Harnell": "Additional Voices (voice)", + "Bob Bergen": "Additional Voices (voice)", + "Leslie Jones": "Meena's Mother (voice)", + "Chris Renaud": "Additional Voices (voice)", + "Nick Kroll": "Gunter (voice)", + "Seth MacFarlane": "Mike (voice)", + "Marisa Liz": "Voice 2", + "Áurea": "Voice 1", + "Leo Jennings": "Piglet (voice)", + "Oscar Jennings": "Piglet (voice)", + "Tara Strong": "Additional Voices (voice)", + "John C. Reilly": "Eddie (voice)", + "Matthew McConaughey": "Buster Moon (voice)", + "Caspar Jennings": "Piglet (voice)", + "Daamen J. Krall": "Additional Voices (voice)", + "Tori Kelly": "Meena (voice)", + "Laraine Newman": "Meena's Grandmother / Additional Voices (voice)", + "Willow Geer": "Additional Voices (voice)", + "Wes Anderson": "Additional Voices (voice)", + "Jason Pace": "Additional Voices (voice)", + "Jennifer Saunders": "Nana (voice)", + "John DeMita": "Additional Voices (voice)" + }, + "via_imdb": true, + "images": { + "disc_art": [], + "poster": [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMTYzODYzODU2Ml5BMl5BanBnXkFtZTgwNTc1MTA2NzE@._V1_SX300.jpg" ], + "backdrop": [ "https://image.tmdb.org/t/p/w1280/fxDXp8un4qNY9b1dLd7SH6CKzC.jpg" ], + "extra_thumbs": [], + "poster_original": [ "https://image.tmdb.org/t/p/original/5XFchtGifv8mz4qlyT8PZ7ZsjfG.jpg" ], + "actors": { + "Taron Egerton": "https://image.tmdb.org/t/p/w185/bVsLVoO3BGoHRLjWoM4Gjav2hNb.jpg", + "Catherine Cavadini": "https://image.tmdb.org/t/p/w185/o2wULQltvbzCTCJitNeT72AjklR.jpg", + "Beck Bennett": "https://image.tmdb.org/t/p/w185/oblaqelpyBvtB5GaSgQpDrfka9M.jpg", + "Daamen J. Krall": "https://image.tmdb.org/t/p/w185/u0CORJ8e2vvw1dFARU4estHYS2I.jpg", + "Rhea Perlman": "https://image.tmdb.org/t/p/w185/cq7Cf4z3BHD9o58ki7MgCioty8q.jpg", + "Abby Craden": "https://image.tmdb.org/t/p/w185/biX1xErOEwsuRvidr8Pw6edEyK4.jpg", + "Jim Cummings": "https://image.tmdb.org/t/p/w185/i9frXvIJsGtoFikBEFVqE7uN8Bq.jpg", + "Peter Serafinowicz": "https://image.tmdb.org/t/p/w185/nfXHDKeetwO16agC0S7tDmLt1il.jpg", + "Bill Farmer": "https://image.tmdb.org/t/p/w185/4aDBlkt8nEkr1RkEhiKIbDWhpZB.jpg", + "Jessica Rau": "https://image.tmdb.org/t/p/w185/jBbIYc3UQf7JU8ggQVkfezpmgVZ.jpg", + "Townsend Coleman": "https://image.tmdb.org/t/p/w185/j7PvxQ7XuOQc1ggSRHWRP6CB8CU.jpg", + "Brad Morris": "https://image.tmdb.org/t/p/w185/qX6oVdAt7Vzzcnw28bdXFp05BBH.jpg", + "Doug Burch": "https://image.tmdb.org/t/p/w185/zwfqhPuIFrUL70bWPESdJZWXc7F.jpg", + "Jennifer Hudson": "https://image.tmdb.org/t/p/w185/zqTu7AANIUsVMAYz5rK1YPnvbWR.jpg", + "Asher Blinkoff": "https://image.tmdb.org/t/p/w185/780sIDWQoAIVVaUbAQex50Vam0V.jpg", + "Reese Witherspoon": "https://image.tmdb.org/t/p/w185/a3o8T1P6yy4KWL7wZG6HuDeuh5n.jpg", + "Scarlett Johansson": "https://image.tmdb.org/t/p/w185/f3c1rwcOoeU0v6Ak5loUvMyifR0.jpg", + "Carlos Alazraqui": "https://image.tmdb.org/t/p/w185/o62NevO1Vt9n1MdYsWOsDyhUt3A.jpg", + "Nick Offerman": "https://image.tmdb.org/t/p/w185/8rJOtmxL5GIfNdOfksVPzepQOy2.jpg", + "Sara Mann": "https://image.tmdb.org/t/p/w185/1TiV16ODOJtTZQrWmHRwOyQnMb0.jpg", + "Jay Pharoah": "https://image.tmdb.org/t/p/w185/yRD2vypRF0niEdoCCI0pNZENzvm.jpg", + "Tara Strong": "https://image.tmdb.org/t/p/w185/rFUZnJ4BaSaQVKW734xnUHSN9pm.jpg", + "Garth Jennings": "https://image.tmdb.org/t/p/w185/ahQh5uW5CXLe1LotxN4Y20aj5Gx.jpg", + "Jess Harnell": "https://image.tmdb.org/t/p/w185/k0BOzEyMkZ1CcoCaohjqTyQJjP1.jpg", + "Leslie Jones": "https://image.tmdb.org/t/p/w185/2cXrwJoX0QHGBtNMsMLqeF6bR3s.jpg", + "Chris Renaud": "https://image.tmdb.org/t/p/w185/yK3RxNsIEBljUe9jPG0iz53Iz6t.jpg", + "Nick Kroll": "https://image.tmdb.org/t/p/w185/puZov7sMmuVkvdqJvmlxtWcS1fU.jpg", + "Seth MacFarlane": "https://image.tmdb.org/t/p/w185/v4c6JhGYpjMRBwf95gtPxBnElNu.jpg", + "Bob Bergen": "https://image.tmdb.org/t/p/w185/kuWDjNTw6OVnc3q1ugMGBYpMMMa.jpg", + "Edgar Wright": "https://image.tmdb.org/t/p/w185/ypyH2s4egy5BkviuGDfeltpb19N.jpg", + "Matthew McConaughey": "https://image.tmdb.org/t/p/w185/jdRmHrG0TWXGhs4tO6TJNSoL25T.jpg", + "John C. Reilly": "https://image.tmdb.org/t/p/w185/kUo2TPQp4kOWWvijvkjLl0v9PQB.jpg", + "Adam Buxton": "https://image.tmdb.org/t/p/w185/zL31NlBBKL1NTjR48h610by5Rld.jpg", + "Tori Kelly": "https://image.tmdb.org/t/p/w185/dMyLOIOYqTMQtMEiK9DSxxHTz6F.jpg", + "Laraine Newman": "https://image.tmdb.org/t/p/w185/ApYftBOqDMBnVColOQwXIodOt5s.jpg", + "Willow Geer": "https://image.tmdb.org/t/p/w185/q2TjAxrQSpPPUiTUwFBXcLJ7qxc.jpg", + "Wes Anderson": "https://image.tmdb.org/t/p/w185/r6mr3gvbuocMznHXSlXVKDj7mEI.jpg", + "Jason Pace": "https://image.tmdb.org/t/p/w185/2q6KfNytYUiHuf8Rx9HyBGoD1T7.jpg", + "Jennifer Saunders": "https://image.tmdb.org/t/p/w185/nlxiFy0LUYGlICaFY3rF2DRovcc.jpg", + "John DeMita": "https://image.tmdb.org/t/p/w185/lzwHtcKVd5oenYtoFtJYeNddpwT.jpg" + }, + "backdrop_original": [ "https://image.tmdb.org/t/p/original/fxDXp8un4qNY9b1dLd7SH6CKzC.jpg" ], + "clear_art": [], + "logo": [], + "banner": [], + "landscape": [], + "extra_fanart": [] + }, + "directors": [ "Christophe Lourdelet", "Garth Jennings" ], + "titles": [ "Sing", "Welcome to the Auditions" ], + "imdb": "tt3470600", + "mpaa": "PG", + "via_tmdb": true, + "actors": [ "Matthew McConaughey", "Reese Witherspoon", "Seth MacFarlane", "Scarlett Johansson" ], + "writers": [ "Garth Jennings" ], + "runtime": 110, + "type": "movie", + "released": "21 Dec 2016" + }, + "_t": "media", + "releases": [], + "title": "Sing", + "_rev": "00031b86", + "profile_id": "38699ec285c447bab0bc6267ffb2f3ad", + "_id": "f12dc6bbff294daa85db0d839646442a", + "category_id": null, + "type": "movie", + "files": { "image_poster": [ "C:\\Users\\devin\\AppData\\Roaming\\CouchPotato\\cache\\2ad327d73e8ef4deab7a4b564d3b9cb4.jpg" ] }, + "identifiers": { "imdb": "tt3470600" } + }, + { + "status": "active", + "info": { + "rating": { "imdb": [ 6.4, 10027 ] }, + "genres": [ "Action", "Horror" ], + "tmdb_id": 346672, + "plot": "Vampire death dealer Selene fends off brutal attacks from both the Lycan clan and the Vampire faction that betrayed her. With her only allies, David and his father Thomas, she must stop the eternal war between Lycans and Vampires, even if it means she has to make the ultimate sacrifice.", + "tagline": "Protect the Bloodline", + "release_date": { + "dvd": 1493589600, + "expires": 1485114954, + "theater": 1483657200, + "bluray": true + }, + "year": 2016, + "original_title": "Underworld: Blood Wars", + "actor_roles": { + "India Eisley": "Eve", + "Kate Beckinsale": "Selene", + "Oliver Stark": "Gregor", + "Brian Caspe": "Hajna", + "Charles Dance": "Thomas", + "Alicia Vela-Bailey": "Safehouse Lycan", + "Bradley James": "Varga", + "David Bowles": "Grey Lycan", + "Theo James": "David", + "Lara Pulver": "Semira", + "Eva Larvoire": "Tech Lycan", + "Tobias Menzies": "Marius", + "Daisy Head": "Alexia", + "Trent Garrett": "Hybrid Michael" + }, + "via_imdb": true, + "images": { + "disc_art": [], + "poster": [ "https://images-na.ssl-images-amazon.com/images/M/MV5BMjI5Njk0NTIyNV5BMl5BanBnXkFtZTgwNjU4MjY5MDI@._V1_SX300.jpg" ], + "backdrop": [ "https://image.tmdb.org/t/p/w1280/PIXSMakrO3s2dqA7mCvAAoVR0E.jpg" ], + "extra_thumbs": [], + "poster_original": [ "https://image.tmdb.org/t/p/original/nHXiMnWUAUba2LZ0dFkNDVdvJ1o.jpg" ], + "actors": { + "India Eisley": "https://image.tmdb.org/t/p/w185/njL744BT8mz9jf2TxcZDnSOEZFb.jpg", + "Kate Beckinsale": "https://image.tmdb.org/t/p/w185/pTRtcZn9gWQZRiet36qWKh94urn.jpg", + "Oliver Stark": "https://image.tmdb.org/t/p/w185/5yULYfaUMymZdSLhk2W96hZIQBP.jpg", + "Brian Caspe": "https://image.tmdb.org/t/p/w185/1fDVsCwZOwp97Pdl7q743seHCMP.jpg", + "Charles Dance": "https://image.tmdb.org/t/p/w185/bLT03rnI29YmbYWjA1JJCl4xVXw.jpg", + "Alicia Vela-Bailey": "https://image.tmdb.org/t/p/w185/kVuyn6sS7ZSBlXVjjxq0LSE3k4I.jpg", + "Bradley James": "https://image.tmdb.org/t/p/w185/4XAtJsz67pmpIsCQ9SBKfqayk2d.jpg", + "Trent Garrett": "https://image.tmdb.org/t/p/w185/w9J2snV7QI71B5F7rCxfPqeS7GU.jpg", + "Theo James": "https://image.tmdb.org/t/p/w185/hLNSoQ3gc52X5VVb172yO3CuUEq.jpg", + "Eva Larvoire": "https://image.tmdb.org/t/p/w185/Aq96CWP3Pub2CdWSNbL5eaTwRt0.jpg", + "Tobias Menzies": "https://image.tmdb.org/t/p/w185/bXUpxFsIowySRyyqchaE1XprptI.jpg", + "Daisy Head": "https://image.tmdb.org/t/p/w185/33JAZTxDWj646mxdW1HksqHOsiY.jpg", + "Lara Pulver": "https://image.tmdb.org/t/p/w185/ve68vtNYVXmKjzn81zKhI7TWEvy.jpg" + }, + "backdrop_original": [ "https://image.tmdb.org/t/p/original/PIXSMakrO3s2dqA7mCvAAoVR0E.jpg" ], + "clear_art": [], + "logo": [], + "banner": [], + "landscape": [], + "extra_fanart": [] + }, + "directors": [ "Anna Foerster" ], + "titles": [ "Underworld: Blood Wars", "Inframundo: Guerras de Sangre", "Anjos da Noite: Guerras de Sangue", "Underworld Reboot", "Underworld: Next Generation", "決戰異世界:弒血之戰", "Інший світ 5: Кровна помста", "Інший світ 5", "Underworld 5 - Blood Wars" ], + "imdb": "tt3717252", + "mpaa": "R", + "via_tmdb": true, + "actors": [ "Kate Beckinsale", "Theo James", "Tobias Menzies", "Lara Pulver" ], + "writers": [ "Cory Goodman (screenplay)", "Kyle Ward (story by)", "Cory Goodman (story by)", "Kevin Grevioux (based on characters created by)", "Len Wiseman (based on characters created by)", "Danny McBride (based on characters created by)" ], + "runtime": 91, + "type": "movie", + "released": "06 Jan 2017" + }, + "_t": "media", + "releases": [], + "title": "Underworld: Blood Wars", + "_rev": "00037887", + "profile_id": "38699ec285c447bab0bc6267ffb2f3ad", + "_id": "4040237fdbd349629a51e29e8ff634f2", + "category_id": null, + "type": "movie", + "files": { "image_poster": [ "C:\\Users\\devin\\AppData\\Roaming\\CouchPotato\\cache\\e41f29a177dd6756dce94f24148c81fe.jpg" ] }, + "identifiers": { "imdb": "tt3717252" } + } + ], + "total": 3, + "empty": false, + "success": true +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/NetImport/CouchPotato/CouchPotatoParserFixture.cs b/src/NzbDrone.Core.Test/NetImport/CouchPotato/CouchPotatoParserFixture.cs new file mode 100644 index 000000000..cfea7ae36 --- /dev/null +++ b/src/NzbDrone.Core.Test/NetImport/CouchPotato/CouchPotatoParserFixture.cs @@ -0,0 +1,37 @@ +using System.Linq; +using System.Text; +using FluentAssertions; +using Moq; +using NUnit.Framework; +using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.NetImport; +using NzbDrone.Core.NetImport.CouchPotato; +using NzbDrone.Core.NetImport.RSSImport; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.NetImport.CouchPotato +{ + public class CouchPotatoTest : CoreTest + { + private NetImportResponse CreateResponse(string url, string content) + { + var httpRequest = new HttpRequest(url); + var httpResponse = new HttpResponse(httpRequest, new HttpHeader(), Encoding.UTF8.GetBytes(content)); + + return new NetImportResponse(new NetImportRequest(httpRequest), httpResponse); + } + + + [Test] + public void should_parse_json_of_couchpotato() + { + var json = ReadAllText("Files/couchpotato_movie_list.json"); + + var result = Subject.ParseResponse(CreateResponse("http://my.indexer.com/api?q=My+Favourite+Show", json)); + + result.First().Title.Should().Be("Rogue One: A Star Wars Story"); + result.First().ImdbId.Should().Be("tt3748528"); + } + } +} \ No newline at end of file diff --git a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a563c9f31..8cf473015 100644 --- a/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/src/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -190,6 +190,9 @@ + + Always + Always @@ -284,6 +287,7 @@ + diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoAPI.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoAPI.cs index 830202896..1fc3a3362 100644 --- a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoAPI.cs +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoAPI.cs @@ -3,91 +3,88 @@ using System.Xml.Serialization; namespace NzbDrone.Core.NetImport.CouchPotato { - class CouchPotatoAPI + public class CouchPotatoResponse { - public class CouchPotatoResponse - { - public Movie[] movies { get; set; } - public int total { get; set; } - public bool empty { get; set; } - public bool success { get; set; } - } + public Movie[] movies { get; set; } + public int total { get; set; } + public bool empty { get; set; } + public bool success { get; set; } + } - public class Movie - { - public string status { get; set; } - public Info info { get; set; } - public string _t { get; set; } - public List releases { get; set; } - public string title { get; set; } - public string _rev { get; set; } - public string profile_id { get; set; } - public string _id { get; set; } - public object category_id { get; set; } - public string type { get; set; } - } + public class Movie + { + public string status { get; set; } + public Info info { get; set; } + public string _t { get; set; } + public List releases { get; set; } + public string title { get; set; } + public string _rev { get; set; } + public string profile_id { get; set; } + public string _id { get; set; } + public object category_id { get; set; } + public string type { get; set; } + } - public class Info - { - public string[] genres { get; set; } - public int tmdb_id { get; set; } - public string plot { get; set; } - public string tagline { get; set; } - public int year { get; set; } - public string original_title { get; set; } - public bool via_imdb { get; set; } - public string[] directors { get; set; } - public string[] titles { get; set; } - public string imdb { get; set; } - public string mpaa { get; set; } - public bool via_tmdb { get; set; } - public string[] actors { get; set; } - public string[] writers { get; set; } - public int runtime { get; set; } - public string type { get; set; } - public string released { get; set; } - } + public class Info + { + public string[] genres { get; set; } + public int tmdb_id { get; set; } + public string plot { get; set; } + public string tagline { get; set; } + public int year { get; set; } + public string original_title { get; set; } + public bool via_imdb { get; set; } + public string[] directors { get; set; } + public string[] titles { get; set; } + public string imdb { get; set; } + public string mpaa { get; set; } + public bool via_tmdb { get; set; } + public string[] actors { get; set; } + public string[] writers { get; set; } + public int runtime { get; set; } + public string type { get; set; } + public string released { get; set; } + } - public class ReleaseInfo - { - public int size { get; set; } - public int seeders { get; set; } - public string protocol { get; set; } - public string description { get; set; } - public string url { get; set; } - public int age { get; set; } - public string id { get; set; } - public int leechers { get; set; } - public int score { get; set; } - public string provider { get; set; } - public int seed_time { get; set; } - public string provider_extra { get; set; } - public string detail_url { get; set; } - public string type { get; set; } - public double seed_ratio { get; set; } - public string name { get; set; } - } + public class ReleaseInfo + { + public int size { get; set; } + public int seeders { get; set; } + public string protocol { get; set; } + public string description { get; set; } + public string url { get; set; } + public int age { get; set; } + public string id { get; set; } + public int leechers { get; set; } + public int score { get; set; } + public string provider { get; set; } + public int seed_time { get; set; } + public string provider_extra { get; set; } + public string detail_url { get; set; } + public string type { get; set; } + public double seed_ratio { get; set; } + public string name { get; set; } + } - public class DownloadInfo - { - public bool status_support { get; set; } - public string id { get; set; } - public string downloader { get; set; } - } + public class DownloadInfo + { + public bool status_support { get; set; } + public string id { get; set; } + public string downloader { get; set; } + } - public class Release - { - public string status { get; set; } - public ReleaseInfo info { get; set; } - public DownloadInfo download_info { get; set; } - public string _id { get; set; } - public string media_id { get; set; } - public string _rev { get; set; } - public string _t { get; set; } - public bool is_3d { get; set; } - public int last_edit { get; set; } - public string identifier { get; set; } - public string quality { get; set; } - } + public class Release + { + public string status { get; set; } + public ReleaseInfo info { get; set; } + public DownloadInfo download_info { get; set; } + public string _id { get; set; } + public string media_id { get; set; } + public string _rev { get; set; } + public string _t { get; set; } + public bool is_3d { get; set; } + public int last_edit { get; set; } + public string identifier { get; set; } + public string quality { get; set; } } } diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs new file mode 100644 index 000000000..fbaf7055e --- /dev/null +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoParser.cs @@ -0,0 +1,106 @@ +using Newtonsoft.Json; +using NzbDrone.Core.NetImport.Exceptions; +using NzbDrone.Core.Tv; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Text; +using System.Text.RegularExpressions; +using System.Windows.Forms; +using System.Xml; +using System.Xml.Linq; +using NLog; +using NzbDrone.Common.Extensions; +using NzbDrone.Common.Http; +using NzbDrone.Core.Indexers; +using NzbDrone.Core.Indexers.Exceptions; +using NzbDrone.Core.Parser.Model; + +namespace NzbDrone.Core.NetImport.CouchPotato +{ + public class CouchPotatoParser : IParseNetImportResponse + { + private readonly CouchPotatoSettings _settings; + private NetImportResponse _importResponse; + private readonly Logger _logger; + + private static readonly Regex ReplaceEntities = new Regex("&[a-z]+;", RegexOptions.Compiled | RegexOptions.IgnoreCase); + + public CouchPotatoParser(CouchPotatoSettings settings) + { + _settings = settings; + } + + public IList ParseResponse(NetImportResponse importResponse) + { + _importResponse = importResponse; + + var movies = new List(); + + if (!PreProcess(_importResponse)) + { + return movies; + } + + var jsonResponse = JsonConvert.DeserializeObject(_importResponse.Content); + + // no movies were return + if (jsonResponse.total == 0) + { + return movies; + } + + var responseData = jsonResponse.movies; + + foreach (var item in responseData) + { + // if there are no releases at all the movie wasn't found on CP, so return movies + if (!item.releases.Any() && item.type == "movie") + { + movies.AddIfNotNull(new Tv.Movie() + { + Title = item.title, + ImdbId = item.info.imdb, + TmdbId = item.info.tmdb_id + }); + } + else + { + // snatched,missing,available,downloaded + // done,seeding + bool isCompleted = item.releases.Any(rel => (rel.status == "done" || rel.status == "seeding")); + if (!isCompleted) + { + movies.AddIfNotNull(new Tv.Movie() + { + Title = item.title, + ImdbId = item.info.imdb, + TmdbId = item.info.tmdb_id + }); + } + } + } + + return movies; + } + + protected virtual bool PreProcess(NetImportResponse indexerResponse) + { + if (indexerResponse.HttpResponse.StatusCode != HttpStatusCode.OK) + { + throw new NetImportException(indexerResponse, "Indexer API call resulted in an unexpected StatusCode [{0}]", indexerResponse.HttpResponse.StatusCode); + } + + if (indexerResponse.HttpResponse.Headers.ContentType != null && indexerResponse.HttpResponse.Headers.ContentType.Contains("text/json") && + indexerResponse.HttpRequest.Headers.Accept != null && !indexerResponse.HttpRequest.Headers.Accept.Contains("text/json")) + { + throw new NetImportException(indexerResponse, "Indexer responded with html content. Site is likely blocked or unavailable."); + } + + return true; + } + + } +} diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoRequestGenerator.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoRequestGenerator.cs new file mode 100644 index 000000000..8fc5a4947 --- /dev/null +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoRequestGenerator.cs @@ -0,0 +1,28 @@ +using NzbDrone.Common.Http; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace NzbDrone.Core.NetImport.CouchPotato +{ + public class CouchPotatoRequestGenerator : INetImportRequestGenerator + { + public CouchPotatoSettings Settings { get; set; } + + public virtual NetImportPageableRequestChain GetMovies() + { + var pageableRequests = new NetImportPageableRequestChain(); + + pageableRequests.Add(GetMovies(null)); + + return pageableRequests; + } + + private IEnumerable GetMovies(string searchParameters) + { + var request = new NetImportRequest($"{Settings.Link.Trim()}:{Settings.Port}/api/{Settings.ApiKey}/movie.list/?status=active", HttpAccept.Json); + yield return request; + } + } +} diff --git a/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoSettings.cs b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoSettings.cs new file mode 100644 index 000000000..08eec552b --- /dev/null +++ b/src/NzbDrone.Core/NetImport/CouchPotato/CouchPotatoSettings.cs @@ -0,0 +1,26 @@ +using FluentValidation; +using NzbDrone.Core.Annotations; +using NzbDrone.Core.Profiles; +using NzbDrone.Core.ThingiProvider; +using NzbDrone.Core.Validation; + +namespace NzbDrone.Core.NetImport.CouchPotato +{ + + public class CouchPotatoSettings : NetImportBaseSettings + { + public CouchPotatoSettings() + { + Link = "http://localhost"; + } + + [FieldDefinition(0, Label = "CouchPotato URL", HelpText = "Link to your CoouchPootato.")] + public new string Link { get; set; } + + [FieldDefinition(1, Label = "CouchPotato Port", HelpText = "Port your CoouchPootato uses.")] + public string Port { get; set; } + + [FieldDefinition(2, Label = "CouchPotato API Key", HelpText = "CoouchPootato API Key.")] + public string ApiKey { get; set; } + } +} diff --git a/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListAPI.cs b/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListAPI.cs deleted file mode 100644 index ccc618e9c..000000000 --- a/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListAPI.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System.Collections.Generic; -using System.Xml.Serialization; - -namespace NzbDrone.Core.NetImport.RSSImport -{ - class IMDbWatchListAPI - { - [XmlRoot(ElementName = "item")] - public class Movie - { - [XmlElement(ElementName = "pubDate")] - public string PublishDate { get; set; } - [XmlElement(ElementName = "title")] - public string Title { get; set; } - [XmlElement(ElementName = "link")] - public string Link { get; set; } - [XmlElement(ElementName = "guid")] - public string Guid { get; set; } - [XmlElement(ElementName = "description")] - public string Description { get; set; } - } - - [XmlRoot(ElementName = "channel")] - public class Channel - { - [XmlElement(ElementName = "title")] - public string Title { get; set; } - [XmlElement(ElementName = "link")] - public string Link { get; set; } - [XmlElement(ElementName = "description")] - public string Description { get; set; } - [XmlElement(ElementName = "pubDate")] - public string PublishDate { get; set; } - [XmlElement(ElementName = "lastBuildDate")] - public string LastBuildDate { get; set; } - [XmlElement(ElementName = "item")] - public List Movie { get; set; } - } - } -} diff --git a/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListProxy.cs b/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListProxy.cs deleted file mode 100644 index 0d46198f4..000000000 --- a/src/NzbDrone.Core/NetImport/RSSImport/IMDbWatchListProxy.cs +++ /dev/null @@ -1,79 +0,0 @@ -using System; -using System.Linq; -using System.Net; -using System.Xml.Linq; -using FluentValidation.Results; -using NLog; -using NzbDrone.Core.Exceptions; -using RestSharp; -using NzbDrone.Core.Rest; - -namespace NzbDrone.Core.NetImport.RSSImport -{ - public interface IIMDbWatchListProxy - { - void ImportMovies(string url); - ValidationFailure Test(RSSImportSettings settings); - } - - public class IMDbWatchListProxy : IIMDbWatchListProxy - { - private readonly Logger _logger; - private const string URL = "http://rss.imdb.com"; - - public IMDbWatchListProxy(Logger logger) - { - _logger = logger; - } - - public void ImportMovies(string id) - { - var client = RestClientFactory.BuildClient(URL); - var request = new RestRequest("/list/{id}", Method.GET); - request.RequestFormat = DataFormat.Xml; - request.AddParameter("id", id, ParameterType.UrlSegment); - - var response = client.ExecuteAndValidate(request); - ValidateResponse(response); - } - - private void Verify(string id) - { - var client = RestClientFactory.BuildClient(URL); - var request = new RestRequest("/list/{id}", Method.GET); - request.RequestFormat = DataFormat.Xml; - request.AddParameter("id", id, ParameterType.UrlSegment); - - var response = client.ExecuteAndValidate(request); - ValidateResponse(response); - } - - private void ValidateResponse(IRestResponse response) - { - var xDoc = XDocument.Parse(response.Content); - var nma = xDoc.Descendants("nma").Single(); - var error = nma.Descendants("error").SingleOrDefault(); - - if (error != null) - { - ((HttpStatusCode)Convert.ToInt32(error.Attribute("code").Value)).VerifyStatusCode(error.Value); - } - } - - public ValidationFailure Test(RSSImportSettings settings) - { - try - { - Verify(settings.Link); - ImportMovies(settings.Link); - } - catch (Exception ex) - { - _logger.Error(ex, "Unable to import movies: " + ex.Message); - return new ValidationFailure("IMDbWatchListId", "Unable to import movies"); - } - - return null; - } - } -} diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportRequestGenerator.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportRequestGenerator.cs index a28068a07..534f2cda1 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportRequestGenerator.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportRequestGenerator.cs @@ -20,10 +20,10 @@ namespace NzbDrone.Core.NetImport.RSSImport return pageableRequests; } - public NetImportPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) - { - return new NetImportPageableRequestChain(); - } + //public NetImportPageableRequestChain GetSearchRequests(MovieSearchCriteria searchCriteria) + //{ + // return new NetImportPageableRequestChain(); + //} private IEnumerable GetMovies(string searchParameters) { diff --git a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs index f4fb783c7..af39fe2ae 100644 --- a/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs +++ b/src/NzbDrone.Core/NetImport/RSSImport/RSSImportSettings.cs @@ -14,7 +14,6 @@ namespace NzbDrone.Core.NetImport.RSSImport public RSSImportSettings() { Link = "http://rss.yoursite.com"; - ProfileId = 1; } [FieldDefinition(0, Label = "RSS Link", HelpText = "Link to the rss feed of movies.")] diff --git a/src/NzbDrone.Core/NzbDrone.Core.csproj b/src/NzbDrone.Core/NzbDrone.Core.csproj index 8829ff8be..ea58ca869 100644 --- a/src/NzbDrone.Core/NzbDrone.Core.csproj +++ b/src/NzbDrone.Core/NzbDrone.Core.csproj @@ -123,6 +123,10 @@ + + + + @@ -131,7 +135,6 @@ - @@ -141,7 +144,6 @@ - @@ -1279,9 +1281,7 @@ - - - +