Code Duplication    Length = 30-34 lines in 2 locations

Trakttv.bundle/Contents/Libraries/Shared/plugin/sync/modes/core/base/mode.py 2 locations

@@ 257-290 (lines=34) @@
254
255
        return True, guid
256
257
    @elapsed.clock
258
    def process_guid_episode(self, guid, season_num, episode_num):
259
        if not guid:
260
            return False, guid, season_num, episode_num
261
262
        if guid.service not in GUID_SERVICES:
263
            # Try map episode to a supported service (via OEM)
264
            supported, match = ModuleManager['mapper'].map_episode(guid, season_num, episode_num)
265
266
            if not supported:
267
                return False, guid, season_num, episode_num
268
269
            if match and match.identifiers:
270
                if isinstance(match, EpisodeMatch) and match.absolute_num is not None:
271
                    log.info('[%s/%s] - Episode mappings with absolute numbers are not supported yet', guid.service, guid.id)
272
                    return False, guid, season_num, episode_num
273
274
                # Retrieve mapped show identifier
275
                service = match.identifiers.keys()[0]
276
                key = try_convert(match.identifiers[service], int, match.identifiers[service])
277
278
                if type(key) not in [int, str]:
279
                    log.info('[%s/%s] - Unsupported key: %r', guid.service, guid.id, key)
280
                    return False, guid, season_num, episode_num
281
282
                log.debug('[%s/%s] (S%02dE%02d) - Mapped to: %r', guid.service, guid.id, season_num, episode_num, match)
283
284
                # Return mapped episode result
285
                return True, Guid.construct(service, key), match.season_num, match.episode_num
286
287
            log.debug('Unable to find mapping for %r S%02dE%02d', guid, season_num, episode_num)
288
            return False, guid, season_num, episode_num
289
290
        return True, guid, season_num, episode_num
291
292
    def sections(self, section_type=None):
293
        # Retrieve "section" for current task
@@ 226-255 (lines=30) @@
223
    def is_data_enabled(self, data):
224
        return data in self.enabled_data
225
226
    @elapsed.clock
227
    def process_guid(self, guid):
228
        if not guid:
229
            return False, guid
230
231
        if guid.service not in GUID_SERVICES:
232
            # Try map show to a supported service (via OEM)
233
            supported, item = ModuleManager['mapper'].match(guid.service, guid.id)
234
235
            if not supported:
236
                return False, guid
237
238
            if item and item.identifiers:
239
                # Retrieve mapped show identifier
240
                service = item.identifiers.keys()[0]
241
                key = try_convert(item.identifiers[service], int, item.identifiers[service])
242
243
                if type(key) not in [int, str]:
244
                    log.info('[%s/%s] - Unsupported key: %r', guid.service, guid.id, key)
245
                    return False, guid
246
247
                log.debug('[%s/%s] - Mapped to: %r', guid.service, guid.id, item)
248
249
                # Return mapped guid
250
                return True, Guid.construct(service, key)
251
252
            log.debug('Unable to find mapping for %r', guid)
253
            return False, guid
254
255
        return True, guid
256
257
    @elapsed.clock
258
    def process_guid_episode(self, guid, season_num, episode_num):