Skip to content

Commit

Permalink
add handling for subtitles for EPISODES for bulkCreation
Browse files Browse the repository at this point in the history
  • Loading branch information
dularion committed May 19, 2019
1 parent 9694af1 commit 74ad5a0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function modalCreateFromFileCtrl($scope, $uibModalInstance, apiService, uploadSe
}

function openAdminForm(mediaObject) {
var url = $state.href('admin.' + mediaObject.importedType, {showId: mediaObject.importedId, movieId: mediaObject.importedId});
var url = $state.href('admin.' + mediaObject.importedType, {showId: mediaObject.importedId, movieId: mediaObject.importedId, season: mediaObject.season});
window.open(url,'_blank');
}

Expand Down
15 changes: 12 additions & 3 deletions grails-app/services/streama/BulkCreateService.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class BulkCreateService {
def seasonNumber = tvShowMatcher.group('Season').toInteger()
def episodeNumber = tvShowMatcher.group('Episode').toInteger()
fileResult.type = "tv"
Boolean isSubtitle = VideoHelper.isSubtitleFile(fileResult.file)

try {
TvShow existingTvShow
Expand All @@ -153,7 +154,11 @@ class BulkCreateService {

if(!seasonNumber && !episodeNumber){
if(existingTvShow){
fileResult.status = MATCHER_STATUS.EXISTING
if(isSubtitle){
fileResult.status = MATCHER_STATUS.EXISTING_FOR_SUBTITLE
}else{
fileResult.status = MATCHER_STATUS.EXISTING
}
fileResult.importedId =existingTvShow.id
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
}
Expand All @@ -168,6 +173,9 @@ class BulkCreateService {
fileResult.name = name
}
fileResult.status = fileResult.status ?: MATCHER_STATUS.MATCH_FOUND
if(fileResult.status == MATCHER_STATUS.MATCH_FOUND && isSubtitle){
fileResult.status = MATCHER_STATUS.SUBTITLE_MATCH
}
fileResult.message = 'match found'
fileResult.type = fileResult.type
fileResult.season = seasonNumber
Expand All @@ -176,6 +184,7 @@ class BulkCreateService {

private extractDataForEpisode(TvShow existingTvShow, seasonNumber, episodeNumber, fileResult, tvShowId) {
fileResult.type = 'episode'
Boolean isSubtitle = VideoHelper.isSubtitleFile(fileResult.file)
Episode existingEpisode

if (existingTvShow) {
Expand All @@ -188,7 +197,7 @@ class BulkCreateService {
}

if (existingEpisode) {
fileResult.status = MATCHER_STATUS.EXISTING
fileResult.status = isSubtitle ? MATCHER_STATUS.EXISTING_FOR_SUBTITLE : MATCHER_STATUS.EXISTING
fileResult.importedId = existingEpisode.showId
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
fileResult.apiId = existingEpisode.apiId
Expand All @@ -197,7 +206,7 @@ class BulkCreateService {
def episodeResult = theMovieDbService.getEpisodeMeta(tvShowId, seasonNumber, episodeNumber)
existingEpisode = Episode.findByApiIdAndDeletedNotEqual(episodeResult.id, true)
if (existingEpisode) {
fileResult.status = MATCHER_STATUS.EXISTING
fileResult.status = isSubtitle ? MATCHER_STATUS.EXISTING_FOR_SUBTITLE : MATCHER_STATUS.EXISTING
fileResult.importedId = existingEpisode.showId
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
}
Expand Down

0 comments on commit 74ad5a0

Please sign in to comment.