@@ 155-199 (lines=45) @@ | ||
152 | t_item=t_item |
|
153 | ) |
|
154 | ||
155 | def update_full(self, data, p_playlist, p_sections_map, t_list=None, t_list_items=None): |
|
156 | # Construct playlist mapper |
|
157 | mapper = PlaylistMapper(self.current, p_sections_map) |
|
158 | ||
159 | # Parse plex playlist items |
|
160 | mapper.plex.load(p_playlist) |
|
161 | ||
162 | # Parse trakt list items |
|
163 | mapper.trakt.load(t_list, t_list_items) |
|
164 | ||
165 | # Match playlist items and expand shows/seasons |
|
166 | m_trakt, m_plex = mapper.match() |
|
167 | ||
168 | log.debug( |
|
169 | 'Update - Mapper Result (%d items)\nt_items:\n%s\n\np_items:\n%s', |
|
170 | len(m_trakt) + len(m_plex), |
|
171 | '\n'.join(self.format_mapper_result(m_trakt)), |
|
172 | '\n'.join(self.format_mapper_result(m_plex)) |
|
173 | ) |
|
174 | ||
175 | # Iterate over matched trakt items |
|
176 | for key, index, (p_index, p_items), (t_index, t_items) in m_trakt: |
|
177 | # Expand shows/seasons into episodes |
|
178 | for p_item, t_item in self.expand(p_items, t_items): |
|
179 | if not t_item: |
|
180 | continue |
|
181 | ||
182 | # Get `SyncMedia` for `t_item` |
|
183 | media = self.get_media(t_item) |
|
184 | ||
185 | if media is None: |
|
186 | log.warn('Unable to identify media of "t_item" (p_item: %r, t_item: %r)', p_item, t_item) |
|
187 | continue |
|
188 | ||
189 | # Execute handler |
|
190 | self.execute_handlers( |
|
191 | self.mode, media, data, |
|
192 | ||
193 | p_sections_map=p_sections_map, |
|
194 | p_playlist=p_playlist, |
|
195 | ||
196 | key=key, |
|
197 | ||
198 | p_item=p_item, |
|
199 | t_item=t_item |
|
200 | ) |
|
201 | ||
202 | def get_changed_lists(self, data, extra=None): |
@@ 37-81 (lines=45) @@ | ||
34 | # Sort list items |
|
35 | self.process_sort(data, p_playlist, p_sections_map, t_list, t_list_items.itervalues()) |
|
36 | ||
37 | def process_update(self, data, p_playlist, p_sections_map, t_list=None, t_list_items=None): |
|
38 | # Construct playlist mapper |
|
39 | mapper = PlaylistMapper(self.current, p_sections_map) |
|
40 | ||
41 | # Parse plex playlist items |
|
42 | mapper.plex.load(p_playlist) |
|
43 | ||
44 | # Parse trakt list items |
|
45 | mapper.trakt.load(t_list, t_list_items) |
|
46 | ||
47 | # Match playlist items and expand shows/seasons |
|
48 | m_trakt, m_plex = mapper.match() |
|
49 | ||
50 | log.debug( |
|
51 | 'Update - Mapper Result (%d items)\nt_items:\n%s\n\np_items:\n%s', |
|
52 | len(m_trakt) + len(m_plex), |
|
53 | '\n'.join(self.format_mapper_result(m_trakt)), |
|
54 | '\n'.join(self.format_mapper_result(m_plex)) |
|
55 | ) |
|
56 | ||
57 | # Iterate over matched trakt items |
|
58 | for key, index, (p_index, p_items), (t_index, t_items) in m_trakt: |
|
59 | # Expand shows/seasons into episodes |
|
60 | for p_item, t_item in self.expand(p_items, t_items): |
|
61 | if not t_item: |
|
62 | continue |
|
63 | ||
64 | # Get `SyncMedia` for `t_item` |
|
65 | media = self.get_media(t_item) |
|
66 | ||
67 | if media is None: |
|
68 | log.warn('Unable to identify media of "t_item" (p_item: %r, t_item: %r)', p_item, t_item) |
|
69 | continue |
|
70 | ||
71 | # Execute handler |
|
72 | self.execute_handlers( |
|
73 | self.mode, media, data, |
|
74 | ||
75 | p_sections_map=p_sections_map, |
|
76 | p_playlist=p_playlist, |
|
77 | ||
78 | key=key, |
|
79 | ||
80 | p_item=p_item, |
|
81 | t_item=t_item |
|
82 | ) |
|
83 | ||
84 | def process_sort(self, data, p_playlist, p_sections_map, t_list, t_list_items): |