Skip to content

Commit

Permalink
A start on trakt.tv integration for episode listings. Looks promising…
Browse files Browse the repository at this point in the history
…, and will resolve tvdb / tvrage matching problems. re #27
  • Loading branch information
SchizoDuckie committed Mar 17, 2014
1 parent 5461a05 commit 89080a8
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -51,7 +51,7 @@ More @ http://imgur.com/gallery/l7toH

Changelog:
==========
* v0.35 : Synchronized versions after another manual screwup, created fully automated deployment process using macro's.
* v0.35 : Synchronized versions after another manual screwup, created fully automated deployment process using macro's. Fixed 10/10 ratings in overview.
* v0.33 : Updated sync option with permanent sync feature. Added functionality for when remote series are deleted. Multiple styling and consistency updates. Synced date formats. Added episode ratings chart on series overview page.
* v0.32 : Added experimental Sync option. Hit the 'sync' button in settings to push your current series list into the cloud. Open DuckieTV on another computer computer (signed in with the same google account), sit back and watch the magic.
* v0.31 : Fixed grid layout for 1200+px wide screens, Fixed naive TVRage id resolving for something more solid. Now matches both by name and optionally firstaired on multiple matches.
Expand Down
1 change: 1 addition & 0 deletions js/app.js
Expand Up @@ -18,6 +18,7 @@ angular.module('DuckieTV', [
'DuckieTV.tvrage',
'DuckieTV.tvrage.sync',
'DuckieTV.thetvdb',
'DuckieTV.trakttv',
'DuckieTV.scenenames',
'DuckieTV.imdb',
'DuckieTV.settingssync',
Expand Down
6 changes: 5 additions & 1 deletion js/controllers.js
Expand Up @@ -48,7 +48,7 @@ angular.module('DuckieTV.controllers',['DuckieTV.settingssync'])

.controller('SerieCtrl',

function(TheTVDB, ThePirateBay, FavoritesService, SettingsService, SceneNameResolver, TVRageSyncService, $routeParams, $scope, $rootScope, $injector, $filter) {
function(TheTVDB, ThePirateBay, FavoritesService, SettingsService, SceneNameResolver, TVRageSyncService, TraktTV, $routeParams, $scope, $rootScope, $injector, $filter) {
console.log('Series controller!', $routeParams.serie, $scope, TheTVDB);
$scope.episodes = [];
$scope.points = [];
Expand Down Expand Up @@ -146,6 +146,10 @@ angular.module('DuckieTV.controllers',['DuckieTV.settingssync'])
TVRageSyncService.syncEpisodes(serie, episodes);
}

$scope.traktSync = function(serie) {
TraktTV.findSeriesByID(serie.TVDB_ID);
}

$scope.searchTorrents = function(serie, episode) {
$scope.items = [];
$scope.searching = true;
Expand Down
75 changes: 75 additions & 0 deletions js/duckietv.trakttv.js
@@ -0,0 +1,75 @@
angular.module('DuckieTV.trakttv',[])
.provider('TraktTV', function() {
this.http = null;
this.promise = null;

this.endpoints = {
seriesSearch: 'http://api.trakt.tv/search/shows.json/32e05d4138adb5da5b702b362bd21c52?query=%s',
seasonSearch: 'http://api.trakt.tv/show/seasons.json/32e05d4138adb5da5b702b362bd21c52/%s',
episodeSearch: 'http://api.trakt.tv/show/season.json/32e05d4138adb5da5b702b362bd21c52/%s/%s'
};

this.parsers = {
season: function(data) {
return data.data;
},

episode: function(data) {
console.log("Parsed episodes!", data.data);
return data.data;
},

search: function(data) {

}
};

this.getUrl = function(type, param, param2) {
var out = this.endpoints[type+'Search'].replace('%s', encodeURIComponent(param));
return (param2 !== undefined) ? out.replace('%s', encodeURIComponent(param2)) : out;
};

this.getParser = function(type) {
return this.parsers[type];
}

this.promiseRequest = function(type, param, param2) {
var d = this.promise.defer();
var url = this.getUrl(type, param, param2);
var parser = this.getParser(type);
this.http({
method: 'GET',
url: url,
cache: true
}).then(function(response) {
d.resolve(parser(response));
}, function(err) {
console.log('error fetching', type);
d.reject(err);
});
return d.promise;
}


this.$get = function($q, $http) {
var self = this;
self.http = $http;
self.promise = $q;
return {
findSeriesByID: function(TVDB_ID) {
var d = self.promise.defer();
self.promiseRequest('season', TVDB_ID).then(function(seasons) {
console.log("Found seasons from trak.tv!", seasons);
$q.all(seasons.map(function(season) {
return self.promiseRequest('episode', TVDB_ID, season.season);
})).then(function(result) {
console.log("All results came in!", result);
d.resolve(result);
});

});
return d.promise;
}
}
}
});
1 change: 1 addition & 0 deletions tab.html
Expand Up @@ -45,6 +45,7 @@
<script src="./js/duckietv.kickasstorrents.js"></script>
<script src="./js/duckietv.tvrage.js"></script>
<script src="./js/duckietv.tvrage.sync.js"></script>
<script src="./js/duckietv.trakttv.js"></script>
<script src="./js/duckietv.scenenames.js"></script>
<script src="./js/duckietv.torrentfreak.js"></script>
<script src="./js/duckietv.thetvdb.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions templates/serie.html
Expand Up @@ -19,6 +19,8 @@
<strong class="dropdown-toggle" style='white-space:nowrap'>Episodes&nbsp;<i class="glyphicon glyphicon-chevron-down"></i></strong>
<ul class="dropdown-menu" style='min-width: 300px'>
<li ng-click="tvRageSync(serie, episodes)"><i class="glyphicon glyphicon-refresh"></i> Sync with TVRage</li>
<li ng-click="traktSync(serie)"><i class="glyphicon glyphicon-refresh"></i> Sync with Trakt.TV</li>

</ul>
</th></th>
<th><strong>Name</strong></th>
Expand Down

0 comments on commit 89080a8

Please sign in to comment.