Parses and set itunes categories
334590
def set_itunes_categories(self):
        """"""
        self.itunes_categories = []
        temp_categories = self.soup.findAll('itunes:category')
        for category in temp_categories:
            category_text = category.get('text')
            self.itunes_categories.append(category_text)
692151
def categorize(category, years)
		categories = category - ['ALL']
		if categories.empty?
			categories = restore_categories
		else
			categories &= restore_categories
		end

		categorized = {}
		begin
			categorized.clear
			categories.each do |c|
				@plugin.__send__(:transaction, 'category') do |db|
					categorized[c] = get(db, c)
				end
				categorized[c].keys.each do |ymd|
					y, m = ymd[0,4], ymd[4,2]
					if years[y].nil? or !years[y].include?(m)
						categorized[c].delete(ymd)
					end
				end
				categorized.delete(c) if categorized[c].empty?
			end
		rescue NoMethodError	# when categorized[c] is nil
			recreate(years)
			retry
		end

		categorized
	end
1018075
def dics_to_itunessd(header_dic, tracks_dics, playlists_dics_and_indexes):
    
    ############################################
    # header
    ######

    header_dic['length'] = get_table_size(header_table)
    header_dic['number_of_tracks'] = len(tracks_dics)
    header_dic['number_of_playlists'] = len(playlists_dics_and_indexes)
    header_dic['number_of_tracks2'] = 0

    header_part_size = get_table_size(header_table)

    ####################################################################################################################
    # tracks
    ##########

    # Chunk of header
    tracks_header_dic = {
        'length': get_table_size(tracks_header_table) + 4 * len(tracks_dics),
        'number_of_tracks': len(tracks_dics)
    }
    tracks_header_chunk = dic_to_chunk(tracks_header_dic, tracks_header_table)

    # Chunk of all tracks

    [track_dic.update({'length': get_table_size(track_table)}) for track_dic in tracks_dics]

    _tracks_chunks = [dic_to_chunk(dic, track_table) for dic in tracks_dics]

    all_tracks_chunck = b''.join(_tracks_chunks)

    # Chunk of offsets
    _length_before_tracks_offsets = header_part_size + len(tracks_header_chunk)
    tracks_offsets_chunck = get_offsets_chunk(_length_before_tracks_offsets, _tracks_chunks)

    # Put chunks together
    track_part_chunk = tracks_header_chunk + tracks_offsets_chunck + all_tracks_chunck

    ####################################################################################################################
    # playlists
    #############

    # Chunk of header
    _playlists_dics = [playlist_indexes[0] for playlist_indexes in playlists_dics_and_indexes]
    _types = [playlist_dic['type'] for playlist_dic in _playlists_dics]
    playlists_header_dic = {
        'length': get_table_size(playlists_header_table) + 4 * len(playlists_dics_and_indexes),
        'number_of_all_playlists': len(_types),
        'flag1': 0xffffffff if _types.count(NORMAL) == 0 else 1,
        'number_of_normal_playlists': _types.count(NORMAL),
        'flag2': 0xffffffff if _types.count(AUDIOBOOK) == 0 else (_types.count(MASTER) + _types.count(NORMAL) +
                                                                  _types.count(PODCAST)),
        'number_of_audiobook_playlists': _types.count(AUDIOBOOK),
        'flag3': 0xffffffff if _types.count(PODCAST) == 0 else _types.count(1) + _types.count(NORMAL),
        'number_of_podcast_playlists': _types.count(PODCAST)
    }
    playlists_header_chunk = dic_to_chunk(playlists_header_dic, playlists_header_table)

    # Chunk of all playlists
    _playlists_chunks = []
    for playlist_header_dic, indexes in playlists_dics_and_indexes:
        dic = playlist_header_dic.copy()
        dic['length'] = get_table_size(playlist_header_table) + 4 * len(indexes)
        dic['number_of_all_track'] = len(indexes)
        dic['number_of_normal_track'] = len(indexes) if dic['type'] in (1, 2) else 0

        if dic['type'] == MASTER:
            header_dic['number_of_tracks2'] = len(indexes)

        _playlist_header_chunk = dic_to_chunk(dic, playlist_header_table)
        _indexes_chunk = b''.join([i.to_bytes(4, 'little') for i in indexes])
        playlist_chunk = _playlist_header_chunk + _indexes_chunk

        _playlists_chunks.append(playlist_chunk)

    all_playlists_chunk = b''.join(_playlists_chunks)

    # Chunk of offsets
    _length_before_playlists_offsets = header_part_size + len(track_part_chunk) + len(playlists_header_chunk)
    playlists_offsets_chunk = get_offsets_chunk(_length_before_playlists_offsets, _playlists_chunks)

    # Put chunks together
    playlists_part_chunk = playlists_header_chunk + playlists_offsets_chunk + all_playlists_chunk

    ########################################################################
    header_dic['tracks_header_offset'] = header_part_size
    header_dic['playlists_header_offset'] = header_part_size + len(track_part_chunk)
    header_part_chunk = dic_to_chunk(header_dic, header_table)
    ########################################################################

    itunessd = header_part_chunk + track_part_chunk + playlists_part_chunk

    return itunessd
1100667
def set_itunes_element(self):
        """"""
        self.set_itunes_author_name()
        self.set_itunes_block()
        self.set_itunes_closed_captioned()
        self.set_itunes_duration()
        self.set_itunes_explicit()
        self.set_itune_image()
        self.set_itunes_order()
        self.set_itunes_subtitle()
        self.set_itunes_summary()
690982
protected function initCategories()
    {
        $collection = $this->getCollection();

        /** @var CategoryModel $category */
        foreach ($collection as $category) {
            $structure = explode('/', $category->getData(CategoryModel::KEY_PATH));
            $pathSize = count($structure);

            if ($pathSize > 1) {
                $path = [];
                for ($i = 1; $i < $pathSize; $i++) {
                    /** @var CategoryModel $c */
                    $c = $collection->getItemById($structure[$i]);
                    $path[] = $c->getData(CategoryModel::KEY_NAME);
                }

                $rootCategoryName = array_shift($path);
                if (!isset($this->categoriesWithRoots[$rootCategoryName])) {
                    $this->categoriesWithRoots[$rootCategoryName] = [];
                }

                $index = $this->implodeEscaped($this->_scopeConfig->getValue(Config::XML_PATH_CATEGORY_PATH_SEPERATOR), $path);
                $this->categoriesWithRoots[$rootCategoryName][$index] = [
                    'entity_id' => $category->getId(),
                    CategoryModel::KEY_PATH => $category->getData(CategoryModel::KEY_PATH),
                    CategoryModel::KEY_LEVEL => $category->getData(CategoryModel::KEY_LEVEL),
                    CategoryModel::KEY_POSITION => $category->getData(CategoryModel::KEY_POSITION)
                ];

                //allow importing by ids.
                if (!isset($this->categoriesWithRoots[$structure[1]])) {
                    $this->categoriesWithRoots[$structure[1]] = [];
                }

                $this->categoriesWithRoots[$structure[1]][$category->getId()] =
                    $this->categoriesWithRoots[$rootCategoryName][$index];
            }
        }

        return $this;

    }
96951
protected function setChildrenCategory()
    {
        $this->data_children = array();

        foreach ($this->data_categories as $item) {
            if (in_array($this->data_category['category_id'], $item['parents'])) {
                $this->data_children[] = $item;
            }
        }
    }
605500
def setup_parse(self, inputstring, document):
        """"""
        self.inputstring = inputstring
        self.document = document
1067996
def set_itunes_subtitle(self):
        """"""
        try:
            self.itunes_subtitle = self.soup.find('itunes:subtitle').string
        except AttributeError:
            self.itunes_subtitle = None
905747
function(category, name, desc) {

            if(used[name]) return;
            used[name]= 1;

            if(!items[category]) items[category] = [];
            
           items[category].push({
               name: name,
               desc: desc
           });
        }
449440
def set_subtitle(self):
        """"""
        try:
            self.subtitle = self.soup.find('itunes:subtitle').string
        except AttributeError:
            self.subtitle = None
1152124
def set_category(self, category):
        
        pcategory = self.find("general/category")
        pcategory.clear()
        name = ElementTree.SubElement(pcategory, "name")
        if isinstance(category, Category):
            id_ = ElementTree.SubElement(pcategory, "id")
            id_.text = category.id
            name.text = category.name
        elif isinstance(category, basestring):
            name.text = category
869309
def parse_setlist_items(setlist_item_array = nil)
        return [] unless setlist_item_array
        setlist_item_array.inject([]) do |setlist_items, item|
          setlist_items << Songkickr::SetlistItem.new(item)
        end
      end
423550
@Override
    public void setCategories(final List<SyndCategory> categories) {
        getDCModule().setSubjects(SyndCategoryListFacade.convertElementsSyndCategoryToSubject(categories));
    }
51091
def load_playlist(self, loc, title):
        '''
        
        '''
        lines = [l.strip() for l in open(loc).readlines()]
        self.playlists.setdefault(title, [])
        self.playlists[title].append(Playlist(lines, True))
409886
function _buildPaths() {
    var home = os.homedir();
    var path1 = path.resolve(home + '/Music/iTunes/iTunes Music Library.xml');
    var path2 = path.resolve(home + '/Music/iTunes/iTunes Library.xml');
    return [path1, path1];
}
1351218
function(category) {
			var settings  = this.getSettings(category);
			for (var i = 0; i < settings.length; i++){
				var label = settings[i].getCategoryLabel();
				if (label) {
					return label;
				}
			}
			return null;
		}
649960
protected function setDataCategoriesEditCategory()
    {
        $category_id = $this->getData('category.category_id');

        if (isset($category_id)) {

            $category_group_id = $this->getData('category_group.category_group_id');

            $options = array(
                'parent_id' => $category_id,
                'category_group_id' => $category_group_id
            );

            $children = $this->category->getTree($options);

            $exclude = array($category_id);
            foreach ($children as $child) {
                $exclude[] = $child['category_id'];
            }

            $categories = $this->getData('categories');
            $modified = array_diff_key($categories, array_flip($exclude));
            $this->setData('categories', $modified);
        }
    }