(self, elem, child, src, srcXML, param)
| 819 | |
| 820 | #syntax: Video, playType (Single|Continuous), key to match (^PlexConnectRatingKey), ratingKey |
| 821 | def TREE_COPY_PLAYLIST(self, elem, child, src, srcXML, param): |
| 822 | tag, leftover = self.getParam(src, param) |
| 823 | playType, leftover, dfltd = self.getKey(src, srcXML, leftover) # Single (default), Continuous |
| 824 | key, leftover, dfltd = self.getKey(src, srcXML, leftover) |
| 825 | param_key = leftover |
| 826 | |
| 827 | src, srcXML, tag = self.getBase(src, srcXML, tag) |
| 828 | |
| 829 | # walk the src path if neccessary |
| 830 | while '/' in tag and src!=None: |
| 831 | parts = tag.split('/',1) |
| 832 | src = src.find(parts[0]) |
| 833 | tag = parts[1] |
| 834 | |
| 835 | # find index of child in elem - to keep consistent order |
| 836 | for ix, el in enumerate(list(elem)): |
| 837 | if el==child: |
| 838 | break |
| 839 | |
| 840 | # filter elements to copy |
| 841 | cnt = 0 |
| 842 | copy_enbl = False |
| 843 | elemsSRC = [] |
| 844 | for elemSRC in src.findall(tag): |
| 845 | child_key, leftover, dfltd = self.getKey(elemSRC, srcXML, param_key) |
| 846 | if not key: |
| 847 | copy_enbl = True # copy all |
| 848 | elif playType == 'Continuous' or playType== 'Shuffle': |
| 849 | copy_enbl = copy_enbl or (key==child_key) # [0 0 1 1 1 1] |
| 850 | else: # 'Single' (default) |
| 851 | copy_enbl = (key==child_key) # [0 0 1 0 0 0] |
| 852 | |
| 853 | if copy_enbl: |
| 854 | elemsSRC.append(elemSRC) |
| 855 | |
| 856 | # shuffle elements |
| 857 | if playType == 'Shuffle': |
| 858 | if not key: |
| 859 | random.shuffle(elemsSRC) # shuffle all |
| 860 | else: |
| 861 | elems = elemsSRC[1:] # keep first element fix |
| 862 | random.shuffle(elems) |
| 863 | elemsSRC = [elemsSRC[0]] + elems |
| 864 | |
| 865 | # duplicate child and add to tree |
| 866 | cnt = 0 |
| 867 | for elemSRC in elemsSRC: |
| 868 | self.PMSroot['copy_'+tag] = elemSRC |
| 869 | self.variables['copy_ix'] = str(cnt) |
| 870 | cnt = cnt+1 |
| 871 | el = copy.deepcopy(child) |
| 872 | XML_ExpandTree(self, el, elemSRC, srcXML) |
| 873 | XML_ExpandAllAttrib(self, el, elemSRC, srcXML) |
| 874 | |
| 875 | if el.tag=='__COPY__': |
| 876 | for el_child in list(el): |
| 877 | elem.insert(ix, el_child) |
| 878 | ix += 1 |
nothing calls this directly
no test coverage detected