Skip to content

Commit

Permalink
add improved error messages for BulkCreation
Browse files Browse the repository at this point in the history
  • Loading branch information
dularion committed May 9, 2019
1 parent b3f8e45 commit 7091255
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<div class="col-md-8">
<i class="ion-document"></i> {{ file.name }}
</div>
<div class="col-md-3">
<div class="col-md-3" style="padding-right: 0;">
<i class="ion-load-c spin column-loading" ng-show="vm.isMatcherLoading && vm.isSelected(file) && (!vm.getMatchForPath(file.path) || vm.getMatchForPath(file.path).status == 1)"></i>
<span ng-if="vm.getMatchForPath(file.path) && vm.getMatchForPath(file.path).status == 1">
<a ng-click="vm.openMediaDetail(vm.getMatchForPath(file.path))"><i class="ion-ios-eye"></i> Match: {{vm.getMatchDisplay(file)}}</a>
Expand All @@ -45,7 +45,7 @@
{{vm.getMatchForPath(file.path).message}}
</span>
<span class="text-danger" ng-if="vm.getMatchForPath(file.path) && vm.getMatchForPath(file.path).status == 4">
TheMovieDB Limit reached
TheMovieDB Error: &nbsp;<i class="ion-help-circled" title="{{vm.getMatchForPath(file.path).errorMessage}}"></i>
</span>

<br>
Expand Down
6 changes: 4 additions & 2 deletions grails-app/services/streama/BulkCreateService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,9 @@ class BulkCreateService {
fileResult.genres = movieResult.genres
}
} catch (Exception ex) {
log.error("Error occured while trying to retrieve data from TheMovieDB. Please check your API-Key.")
log.error("Error occured while trying to retrieve data from TheMovieDB. Please check your API-Key.", ex)
fileResult.status = MATCHER_STATUS.LIMIT_REACHED
fileResult.errorMessage = ex.message
fileResult.title = name
}
fileResult.status = fileResult.status ?: MATCHER_STATUS.MATCH_FOUND
Expand Down Expand Up @@ -149,8 +150,9 @@ class BulkCreateService {
fileResult = extractDataForEpisode(existingTvShow, seasonNumber, episodeNumber, fileResult, tvShowId)
}
} catch (ex) {
log.error("Error occured while trying to retrieve data from TheMovieDB. Please check your API-Key.")
log.error("Error occured while trying to retrieve data from TheMovieDB. Please check your API-Key.", ex)
fileResult.status = MATCHER_STATUS.LIMIT_REACHED
fileResult.errorMessage = ex.message
fileResult.name = name
}
fileResult.status = fileResult.status ?: MATCHER_STATUS.MATCH_FOUND
Expand Down
16 changes: 14 additions & 2 deletions grails-app/services/streama/TheMovieDbService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,12 @@ class TheMovieDbService {
}

def getEpisodeMeta(tvApiId, seasonNumber, episodeNumber){
def JsonContent = new URL(BASE_URL + "/tv/$tvApiId/season/$seasonNumber/episode/$episodeNumber?$API_PARAMS").getText("UTF-8")
URL url = new URL(BASE_URL + "/tv/$tvApiId/season/$seasonNumber/episode/$episodeNumber?$API_PARAMS")
HttpURLConnection conn = url.openConnection()
if(conn.responseCode != 200){
throw new Exception("TMDB request failed with statusCode: " + conn?.responseCode + ", responseMessage: " + conn?.responseMessage)
}
def JsonContent = url.getText("UTF-8")
return new JsonSlurper().parseText(JsonContent)
}

Expand All @@ -139,7 +144,14 @@ class TheMovieDbService {
}
def query = URLEncoder.encode(name, "UTF-8")

def JsonContent = new URL(BASE_URL + '/search/' + type + '?query=' + query + '&api_key=' + API_KEY).getText("UTF-8")

URL url = new URL(BASE_URL + '/search/' + type + '?query=' + query + '&api_key=' + API_KEY)
HttpURLConnection conn = url.openConnection()
log.debug("conn.responseCode: ${conn.responseCode}")
if(conn.responseCode != 200){
throw new Exception("TMDB request failed with statusCode: " + conn?.responseCode + ", responseMessage: " + conn?.responseMessage)
}
def JsonContent = url.getText("UTF-8")
def data = new JsonSlurper().parseText(JsonContent)
apiCacheData["$type:$name"] = data

Expand Down

0 comments on commit 7091255

Please sign in to comment.