Total Complexity | 7 |
Total Lines | 33 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | class HamaMapper(object): |
||
2 | def __init__(self, mapper): |
||
3 | self.mapper = mapper |
||
4 | |||
5 | def map(self, source, key, identifier=None, resolve_mappings=True): |
||
6 | if source == 'tvdb3': |
||
7 | return self.map_tvdb3( |
||
8 | key, |
||
9 | identifier=identifier, |
||
10 | resolve_mappings=resolve_mappings |
||
11 | ) |
||
12 | |||
13 | return False, None |
||
14 | |||
15 | def map_tvdb3(self, key, identifier=None, resolve_mappings=True): |
||
16 | # Find matching anidb service identifier |
||
17 | supported, match = self.mapper.map( |
||
18 | 'tvdb', key, |
||
19 | resolve_mappings=False, |
||
20 | use_handlers=False |
||
21 | ) |
||
22 | |||
23 | if not supported: |
||
24 | return False, None |
||
25 | |||
26 | if not match.identifiers or not match.identifiers.get('anidb'): |
||
27 | return False, None |
||
28 | |||
29 | # Map episode identifier with the `anidb_id` we've found |
||
30 | return self.mapper.map( |
||
31 | 'anidb', match.identifiers['anidb'], |
||
32 | identifier=identifier, |
||
33 | resolve_mappings=resolve_mappings |
||
34 | ) |
||
35 |