コード例 #1
0
        // Creates an TrackData object from an XElement, assumes that the XElement
        // passed is the portion of XML referring to a track entry including
        // and containing the element <dict>
        public TrackInfo(XElement element)
        {
            // This value should always be present, so it is safe to convert without checking
            trackId = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_ID));

            trackTitle  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_NAME);
            artist      = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ARTIST);
            albumArtist = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ALBUM_ARTIST);
            album       = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_ALBUM);
            genre       = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_GENRE);
            kind        = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_KIND);
            trackNumber = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_NUMBER);
            trackCount  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TRACK_COUNT);
            discNumber  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DISC_NUMBER);
            discCount   = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DISC_COUNT);
            year        = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_YEAR);
            comments    = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_COMMENTS);
            compilation = PlistHelper.IsKeyInDict(element, Consts.PLIST_KEY_COMPILATION);

            dateAdded  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_DATE_ADDED);
            lastPlayed = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_LAST_PLAYED);
            playCount  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAY_COUNT);
            rating     = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_RATING);

            totalTime = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_TOTAL_TIME));
            fileSize  = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_SIZE));
            location  = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_LOCATION);
            location  = Uri.UnescapeDataString(location);
            fileName  = System.IO.Path.GetFileName(location);
        }
コード例 #2
0
ファイル: Playlist.cs プロジェクト: macklinb/if2ktool
        public Playlist(XElement element)
        {
            name                 = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_NAME);
            playlistId           = Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAYLIST_ID));
            playlistPersistentId = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAYLIST_PERSISTENT_ID);
            smartInfo            = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAYLIST_SMART_INFO);
            smartCriteria        = PlistHelper.GetValueOfKeyInDict(element, Consts.PLIST_KEY_PLAYLIST_SMART_CRITERIA);

            // Replace line breaks in smartInfo and smartCriteria
            if (smartInfo != null)
            {
                smartInfo = smartInfo.Replace("\n", string.Empty)
                            .Replace("\t", string.Empty);
            }
            if (smartCriteria != null)
            {
                smartCriteria = smartCriteria.Replace("\n", string.Empty)
                                .Replace("\t", string.Empty);
            }

            if (IsSmartPlaylist)
            {
                //iTunes.SmartPlaylistParser.Parse(smartInfo, smartCriteria);

                //byte[] info = Convert.FromBase64String(smartInfo);
                //byte[] criteria = Convert.FromBase64String(smartCriteria);
                //Banshee.Plugins.iTunesImporter.SmartPlaylistParser.Parse(info, criteria);
            }

            // Get array element under playlist dict
            var array = element.Element("array");

            if (array != null)
            {
                var items = new List <int>();

                foreach (var trackDicts in array.Descendants("dict"))
                {
                    items.Add(Convert.ToInt32(PlistHelper.GetValueOfKeyInDict(trackDicts, Consts.PLIST_KEY_TRACK_ID)));
                }

                playlistItems = items.ToArray();
            }
        }