Skip to content

Commit 74ad5a0

Browse files
author
dularion
committed
add handling for subtitles for EPISODES for bulkCreation
1 parent 9694af1 commit 74ad5a0

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

grails-app/assets/javascripts/streama/controllers/createFromFileCtrl.modal.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ function modalCreateFromFileCtrl($scope, $uibModalInstance, apiService, uploadSe
5050
}
5151

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

grails-app/services/streama/BulkCreateService.groovy

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class BulkCreateService {
134134
def seasonNumber = tvShowMatcher.group('Season').toInteger()
135135
def episodeNumber = tvShowMatcher.group('Episode').toInteger()
136136
fileResult.type = "tv"
137+
Boolean isSubtitle = VideoHelper.isSubtitleFile(fileResult.file)
137138

138139
try {
139140
TvShow existingTvShow
@@ -153,7 +154,11 @@ class BulkCreateService {
153154

154155
if(!seasonNumber && !episodeNumber){
155156
if(existingTvShow){
156-
fileResult.status = MATCHER_STATUS.EXISTING
157+
if(isSubtitle){
158+
fileResult.status = MATCHER_STATUS.EXISTING_FOR_SUBTITLE
159+
}else{
160+
fileResult.status = MATCHER_STATUS.EXISTING
161+
}
157162
fileResult.importedId =existingTvShow.id
158163
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
159164
}
@@ -168,6 +173,9 @@ class BulkCreateService {
168173
fileResult.name = name
169174
}
170175
fileResult.status = fileResult.status ?: MATCHER_STATUS.MATCH_FOUND
176+
if(fileResult.status == MATCHER_STATUS.MATCH_FOUND && isSubtitle){
177+
fileResult.status = MATCHER_STATUS.SUBTITLE_MATCH
178+
}
171179
fileResult.message = 'match found'
172180
fileResult.type = fileResult.type
173181
fileResult.season = seasonNumber
@@ -176,6 +184,7 @@ class BulkCreateService {
176184

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

181190
if (existingTvShow) {
@@ -188,7 +197,7 @@ class BulkCreateService {
188197
}
189198

190199
if (existingEpisode) {
191-
fileResult.status = MATCHER_STATUS.EXISTING
200+
fileResult.status = isSubtitle ? MATCHER_STATUS.EXISTING_FOR_SUBTITLE : MATCHER_STATUS.EXISTING
192201
fileResult.importedId = existingEpisode.showId
193202
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
194203
fileResult.apiId = existingEpisode.apiId
@@ -197,7 +206,7 @@ class BulkCreateService {
197206
def episodeResult = theMovieDbService.getEpisodeMeta(tvShowId, seasonNumber, episodeNumber)
198207
existingEpisode = Episode.findByApiIdAndDeletedNotEqual(episodeResult.id, true)
199208
if (existingEpisode) {
200-
fileResult.status = MATCHER_STATUS.EXISTING
209+
fileResult.status = isSubtitle ? MATCHER_STATUS.EXISTING_FOR_SUBTITLE : MATCHER_STATUS.EXISTING
201210
fileResult.importedId = existingEpisode.showId
202211
fileResult.importedType = STREAMA_ROUTES[fileResult.type]
203212
}

0 commit comments

Comments
 (0)