コード例 #1
0
        public Task <IList <Song> > GetSongsAsync(PlaylistType playlistType, string id)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(this.GetRepository <Album>().GetSongsAsync(id));

            case PlaylistType.Artist:
                return(this.GetRepository <Artist>().GetSongsAsync(id));

            case PlaylistType.Genre:
                return(this.GetRepository <Genre>().GetSongsAsync(id));

            case PlaylistType.UserPlaylist:
                return(this.GetRepository <UserPlaylist>().GetSongsAsync(id));

            case PlaylistType.SystemPlaylist:
                return(this.GetRepository <SystemPlaylist>().GetSongsAsync(id));

            case PlaylistType.Radio:
                return(this.radioWebService.GetRadioSongsAsync(id));

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #2
0
        public async Task <int> GetCountAsync(PlaylistType playlistType)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(await this.GetRepository <Album>().GetCountAsync());

            case PlaylistType.Artist:
                return(await this.GetRepository <Artist>().GetCountAsync());

            case PlaylistType.Genre:
                return(await this.GetRepository <Genre>().GetCountAsync());

            case PlaylistType.UserPlaylist:
                return(await this.GetRepository <UserPlaylist>().GetCountAsync());

            case PlaylistType.SystemPlaylist:
                return(await this.GetRepository <SystemPlaylist>().GetCountAsync());

            case PlaylistType.Radio:
                return(1 + await this.GetRepository <Radio>().GetCountAsync());

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #3
0
 /// <summary>
 /// 拡張子を取得する
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 private string GetExt(PlaylistType type)
 {
     return(type switch
     {
         PlaylistType.Aimp => "aimppl4",
         _ => string.Empty,
     });
コード例 #4
0
        public async Task <IEnumerable <IPlaylist> > GetAllAsync(PlaylistType playlistType, Order order, uint?take = null)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(await this.GetRepository <Album>().GetAllAsync(order, take));

            case PlaylistType.Artist:
                return(await this.GetRepository <Artist>().GetAllAsync(order, take));

            case PlaylistType.Genre:
                return(await this.GetRepository <Genre>().GetAllAsync(order, take));

            case PlaylistType.UserPlaylist:
                return(await this.GetRepository <UserPlaylist>().GetAllAsync(order, take));

            case PlaylistType.SystemPlaylist:
                return(await this.GetRepository <SystemPlaylist>().GetAllAsync(order, take));

            case PlaylistType.Radio:
                return((new [] { this.GetLuckyRadio() }).Union(await this.GetRepository <Radio>().GetAllAsync(order, take - 1)));

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #5
0
        public async Task <IEnumerable <IPlaylist> > SearchAsync(PlaylistType playlistType, string searchQuery, uint?take = null)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(await this.GetRepository <Album>().SearchAsync(searchQuery, take));

            case PlaylistType.Artist:
                return(await this.GetRepository <Artist>().SearchAsync(searchQuery, take));

            case PlaylistType.Genre:
                return(await this.GetRepository <Genre>().SearchAsync(searchQuery, take));

            case PlaylistType.UserPlaylist:
                return(await this.GetRepository <UserPlaylist>().SearchAsync(searchQuery, take));

            case PlaylistType.SystemPlaylist:
                return(await this.GetRepository <SystemPlaylist>().SearchAsync(searchQuery, take));

            case PlaylistType.Radio:
                return(await this.GetRepository <Radio>().SearchAsync(searchQuery, take));

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #6
0
 public NativeContainerPlaylist(ISession session, IntPtr handle, IntPtr folderId, PlaylistType type, IPlaylistContainer container)
     : base(session, handle)
 {
     _folderId  = folderId;
     _type      = type;
     _container = container;
 }
コード例 #7
0
        public async Task <IPlaylist> GetAsync(PlaylistType playlistType, string id)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(await this.GetRepository <Album>().GetAsync(id));

            case PlaylistType.Artist:
                return(await this.GetRepository <Artist>().GetAsync(id));

            case PlaylistType.Genre:
                return(await this.GetRepository <Genre>().GetAsync(id));

            case PlaylistType.UserPlaylist:
                return(await this.GetRepository <UserPlaylist>().GetAsync(id));

            case PlaylistType.SystemPlaylist:
                return(await this.GetRepository <SystemPlaylist>().GetAsync(id));

            case PlaylistType.Radio:
                if (string.IsNullOrEmpty(id))
                {
                    return(this.GetLuckyRadio());
                }
                return(await this.GetRepository <Radio>().GetAsync(id));

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #8
0
        /// <summary>
        /// Serializes the <see cref="BrightcoveAudioTrackPlaylist"/>. Note that the <see cref="AudioTracks"/> property is not serialized with the rest of the other properties as the <see cref="AudioTrackIds"/> properties is instead used by Brightcove.
        /// </summary>
        /// <param name="serializer">The serializer.</param>
        /// <returns>
        /// A serialized <see cref="IDictionary{String,Object}" />.
        /// </returns>
        public IDictionary <string, object> Serialize(JavaScriptSerializer serializer)
        {
            IDictionary <string, object> serialized = new Dictionary <string, object>();

            serialized["filterTags"]       = FilterTags;
            serialized["name"]             = Name;
            serialized["playlistType"]     = PlaylistType.ToBrightcoveName();
            serialized["referenceId"]      = ReferenceId;
            serialized["shortDescription"] = ShortDescription;
            serialized["thumbnailURL"]     = ThumbnailUrl;

            // The Id must be non-0.
            if (Id != 0)
            {
                serialized["id"] = Id;
            }

            // Smart playlists (i.e. anything but an Explicit playlist) should not have the VideoIds
            // populated, as 1) Brightcove determines which video Ids belong in a smart playlist, and
            // 2) serializing this property for a smart playlists results in an error.
            //
            // It is still the case that you cannot switch from a smart playlist to an explicit playlist,
            // and attempting to do so will result in an error. A workaround in this case is detailed @
            // https://github.com/BrightcoveOS/.NET-MAPI-Wrapper/wiki/Known-Issues#wiki-convert-smart-playlist-to-explicit.
            if (PlaylistType == PlaylistType.Explicit && AudioTrackIds != null && AudioTrackIds.Any())
            {
                serialized["audioTrackIds"] = AudioTrackIds;
            }

            return(serialized);
        }
コード例 #9
0
 public NativeContainerPlaylist(ISession session, IntPtr handle, IntPtr folderId, PlaylistType type, IPlaylistContainer container)
     : base(session, handle)
 {
     _folderId = folderId;
     _type = type;
     _container = container;
 }
コード例 #10
0
        public string ToString(PlaylistType playlistType)
        {
            if (Type == PlaylistType.UNKNOW)
            {
                return(String.Empty);
            }
            if (!Tracks.Any())
            {
                throw new Exception("No tracks found.");
            }
            if (playlistType != PlaylistType.XPSF &&
                playlistType != PlaylistType.M3U)
            {
                throw new NotImplementedException("Format not implemented yet.");
            }


            var playlist = playlistType == PlaylistType.XPSF
             ? (IPlaylist) new XpsfPlaylist(Tracks)
             : (IPlaylist) new M3UPlaylist(Tracks);

            return(playlist.ToString());

            //return RawData;
        }
コード例 #11
0
        public async Task <ActionResult <IEnumerable <VideoEntity> > > Get([FromQuery] PlaylistType playlistType,
                                                                           [FromHeader] string oauthToken, [FromHeader] string pageToken, [FromHeader] int prefetch)
        {
            if (HasNullOrDefaultArgs(oauthToken, pageToken) || prefetch <= 0)
            {
                return(BadRequest());
            }
            try
            {
                var result = await _homeService.GetPlaylistVideos(oauthToken, playlistType, pageToken, prefetch);

                return(Ok(result));
            }
            catch (GoogleApiException ex)
            {
                if (ex.Error.Code == 401)
                {
                    return(Unauthorized());
                }

                return(StatusCode(500, ex));
            }
            catch (Exception ex)
            {
                return(StatusCode(500, ex));
            }
        }
コード例 #12
0
 public Playlist(PlaylistType type, int id, string title, bool favourite)
 {
     Type      = type;
     Id        = id;
     Title     = title;
     Favourite = favourite;
 }
コード例 #13
0
ファイル: Utils.cs プロジェクト: Namaneo/MyWindowsMediaPlayer
 public static Playlist getPlaylistFromExplorer(PlaylistType type)
 {
     OpenFileDialog ofd = new OpenFileDialog();
     ofd.Filter = Utils.getFilterFromPlaylistType(type);
     ofd.Multiselect = true;
     DialogResult result = ofd.ShowDialog();
     if (result == DialogResult.OK)
     {
         ObservableCollection<Playlist> playlists = PlaylistService.GetPlaylists();
         Playlist pl = new Playlist()
         {
             Id = playlists.Count() > 0 ? playlists.Max(x => x.Id) + 1 : 1,
             Name = DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss"),
             Type = type,
             Elements = new ObservableCollection<Info>()
         };
         for (int i = 0; i < ofd.FileNames.Count(); ++i)
             pl.Elements.Add(new Info()
             {
                 Id = i + 1,
                 Name = ofd.SafeFileNames[i],
                 Path = ofd.FileNames[i],
                 Artist = "",
                 Album = "",
                 Genre = ""
             });
         return pl;
     }
     else
         return null;
 }
コード例 #14
0
    private void GeneratePlaylist(DirectoryInfo dir, bool recursive, bool shuffle)
    {
        this.Response.Buffer      = false;
        this.Response.ContentType = "application/xspf+xml";

        // Allow caching of the non-shuffled playlists.
        // Shuffled ones should be cached because they change every time.
        // Note: since v. 2.0 we have stopped generating shuffled lists
        // and instead generated regular lists and tell the player to do
        // shuffling on its own.
        this.Response.Cache.SetCacheability(shuffle ? HttpCacheability.NoCache : HttpCacheability.Private);
        //if (!shuffle)
        //    this.Response.Cache.SetLastModified(dir.LastAccessTime);

        PlaylistType playlist = new PlaylistType();

        this.RenderPlaylistHeader(dir, playlist);

        List <FileInfo> mediaFiles = new List <FileInfo>();

        UtilityMethods.FindMediaFiles(mediaFiles, dir, recursive);
        this.RenderPlaylistTracks(mediaFiles, playlist, shuffle);

        this.Response.ContentEncoding = System.Text.ASCIIEncoding.UTF8;
        XmlSerializer ser = new XmlSerializer(playlist.GetType());

        ser.Serialize(this.Response.Output, playlist);
    }
コード例 #15
0
        internal static IContainerPlaylist Get(
            ISession session,
            IPlaylistContainer container,
            IntPtr handle,
            IntPtr folderId,
            PlaylistType playlistType)
        {
            KeyGen key = new KeyGen(handle, folderId, playlistType);

            lock (_instanceLock)
            {
                NativeContainerPlaylist instance;

                if (!_instances.TryGetValue(key, out instance))
                {
                    instance = new NativeContainerPlaylist(session, handle, folderId, playlistType, container);
                    instance.Initialize();

                    if (SessionFactory.IsInternalCachingEnabled)
                    {
                        _instances.Add(key, instance);
                    }
                }

                return(instance);
            }
        }
コード例 #16
0
        public async Task <IList <Song> > GetSongsAsync(PlaylistType playlistType, string id)
        {
            switch (playlistType)
            {
            case PlaylistType.Album:
                return(await this.GetRepository <Album>().GetSongsAsync(id));

            case PlaylistType.Artist:
                return(await this.GetRepository <Artist>().GetSongsAsync(id));

            case PlaylistType.Genre:
                return(await this.GetRepository <Genre>().GetSongsAsync(id));

            case PlaylistType.UserPlaylist:
                var playlistRepository = this.GetRepository <UserPlaylist>();
                var playlist           = await playlistRepository.GetAsync(id);

                if (playlist.IsShared)
                {
                    return(await this.userPlaylistsService.GetSharedPlaylistSongsAsync(playlist));
                }
                return(await playlistRepository.GetSongsAsync(id));

            case PlaylistType.SystemPlaylist:
                return(await this.GetRepository <SystemPlaylist>().GetSongsAsync(id));

            case PlaylistType.Radio:
                return(await this.radioStationsService.GetRadioSongsAsync(id));

            default:
                throw new ArgumentOutOfRangeException("playlistType");
            }
        }
コード例 #17
0
        private void mnuPlaylists_DropDownOpening(object sender, EventArgs e)
        {
            normal.RemoveFilterIndex();

            bool radio = controller.RadioMode;

            bool hasSel = normal.HasSelectedTracks;

            mnuPlaylistsAddPlaylist.Enabled        = !radio;
            mnuPlaylistsDeletePlaylist.Enabled     = !radio;
            mnuPlaylistsSwitchToNowPlaying.Enabled = !radio;

            mnuPlaylistsAddSelectedTracksTo.Enabled       = hasSel && !radio;
            mnuPlaylistsAddTracksToTargetPlaylist.Enabled = hasSel && !radio && controller.PlaylistExists(controller.TargetPlaylistName);
            mnuPlayAddTracksToNowPlaying.Enabled          = hasSel && !radio;

            if (controller.TargetPlaylistName.Length > 0)
            {
                mnuPlaylistsAddTracksToTargetPlaylist.Text = Localization.Get(UI_Key.Menu_Playlist_Add_Tracks_To_Playlist, controller.TargetPlaylistName);
            }
            else
            {
                mnuPlaylistsAddTracksToTargetPlaylist.Text = Localization.Get(UI_Key.Menu_Playlist_Add_Tracks_To);
            }

            mnuPlaylistsRemoveSelectedTracksFromPlaylist.Enabled = normal.NondynamicPlaylistBasedView;

            PlaylistType pt = PlaylistType.None;

            bool playlistEnabled = normal.IsFilterActive(FilterType.Playlist);

            if (playlistEnabled)
            {
                pt = Database.GetPlaylistType(normal.ActivePlaylist);
            }

            switch (pt)
            {
            case PlaylistType.Auto:
                mnuPlaylistsEditAutoPlaylist.Enabled          = true;
                mnuPlaylistsConvertToStandardPlaylist.Enabled = true;
                mnuPlaylistsEditAutoPlaylist.Text             = Localization.Get(UI_Key.Menu_Playlist_Edit_Auto_Playlist);
                break;

            case PlaylistType.Standard:
                mnuPlaylistsEditAutoPlaylist.Enabled          = true;
                mnuPlaylistsConvertToStandardPlaylist.Enabled = false;
                mnuPlaylistsEditAutoPlaylist.Text             = Localization.Get(UI_Key.Menu_Playlist_Convert_To_Auto_Playlist);
                break;

            default:
                mnuPlaylistsEditAutoPlaylist.Enabled          = false;
                mnuPlaylistsConvertToStandardPlaylist.Enabled = false;
                mnuPlaylistsRenameSelectedPlaylist.Enabled    = false;
                break;
            }

            mnuPlaylistsSwitchToNowPlaying.Checked = controlPanel.NowPlaying;
        }
コード例 #18
0
 public PlaylistExecuteFromContentRequestBuilder(PlaylistType playlistType, string playlistContent, string detailed, FilterPager pager)
     : this()
 {
     this.PlaylistType    = playlistType;
     this.PlaylistContent = playlistContent;
     this.Detailed        = detailed;
     this.Pager           = pager;
 }
コード例 #19
0
 public PersisterProcessor(IStorage sourceStorage,
                           IStorage targetStorage,
                           PlaylistType targetPlaylistType)
 {
     _sourceStorage      = sourceStorage;
     _targetStorage      = targetStorage;
     _targetPlaylistType = (targetStorage is MtpStorage) ? PlaylistType.M3U : targetPlaylistType;
 }
コード例 #20
0
 internal static void Remove(IntPtr playlistPtr, IntPtr folderId, PlaylistType type)
 {
     lock (_instanceLock)
     {
         KeyGen key = new KeyGen(playlistPtr, folderId, type);
         _instances.Remove(key);
     }
 }
コード例 #21
0
        private static Playlist CreatePlaylist(XElement playlistXml, PlaylistType type)
        {
            var id        = int.Parse(playlistXml.Attribute(PlaylistId).Value);
            var title     = playlistXml.Attribute(PlaylistTitle).Value;
            var favourite = type == PlaylistType.Quick || playlistXml.Attribute(PlaylistIsFavourite)?.Value == TrueValue;

            return(new Playlist(type, id, title, favourite));
        }
コード例 #22
0
 private LastFmTracksList GetTracksResult(PlaylistType type, string result)
 {
     return(type
            switch
     {
         PlaylistType.TopTracks => JsonSerializer.Deserialize <LastFmTopTracksResult>(result).LastFmTracksList,
         PlaylistType.RecentTracks => JsonSerializer.Deserialize <LastFmRecentTracksResult>(result).LastFmTracksList,
         _ => JsonSerializer.Deserialize <LastFmLovedTracksResult>(result).LastFmTracksList,
     });
コード例 #23
0
 public void Reset()
 {
     Type  = PlaylistType.None;
     oNote = new NoteObject();
     oGame = new GameObject();
     game  = null;
     note  = null;
     //iespTICK_Playlist_Details_Get_Results = spTICK_Playlist_Details_Get_Results.GetEnumerator();
 }
コード例 #24
0
 public PlaylistsGroupBindingModel(
     string title,
     int itemsCount,
     IList <PlaylistBindingModel> playlists,
     PlaylistType type)
 {
     this.Title      = title;
     this.Playlists  = playlists;
     this.ItemsCount = itemsCount;
     this.Request    = type;
 }
コード例 #25
0
        public void Save(string path, PlaylistType typ)
        {
            PlaylistWriter playlistWriter = new PlaylistWriter(path, typ);

            playlistWriter.Write(this.itms.ToArray());
            playlistWriter.Close();
            if (this.PlaylistSaved == null)
            {
                return;
            }
            this.PlaylistSaved((object)this, new EventArgs());
        }
コード例 #26
0
        public async Task <long> GetTrackCount(PlaylistType type, string lastFmUser)
        {
            var method = Extensions.GetAttributeNameProperty <PlaylistType, LastFmMethod>(type.ToString());
            var result = await _client.GetAsync($"{_apiUrl}/lastfm/count?user={lastFmUser}&method={method}");

            if (result.IsSuccessStatusCode)
            {
                var model = JsonSerializer.Deserialize <LastFmCount>(await result.Content.ReadAsStringAsync());
                return(model.Count);
            }
            return(0);
        }
コード例 #27
0
        public EditablePlaylistViewModel(string playlistName, PlaylistType type)
        {
            this.playlistName = playlistName;
            this.type         = type;
            this.rules.Add(new SmartPlaylistRuleViewModel());
            this.limit = new SmartPlaylistLimitViewModel(SmartPlaylistLimitType.Songs, 25);

            this.limitTypes.Add(new SmartPlaylistTypeViewModel(SmartPlaylistLimitType.Songs, ResourceUtils.GetString("Language_Smart_Playlist_Songs")));
            this.limitTypes.Add(new SmartPlaylistTypeViewModel(SmartPlaylistLimitType.GigaBytes, ResourceUtils.GetString("Language_Gigabytes_Short")));
            this.limitTypes.Add(new SmartPlaylistTypeViewModel(SmartPlaylistLimitType.MegaBytes, ResourceUtils.GetString("Language_Megabytes_Short")));
            this.limitTypes.Add(new SmartPlaylistTypeViewModel(SmartPlaylistLimitType.Minutes, ResourceUtils.GetString("Language_Smart_Playlist_Minutes")));
            this.selectedLimitType = this.limitTypes.First();
        }
コード例 #28
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="client">(Required) Spotify Sdk Client</param>
 /// <param name="playlistType">(Required) Playlist Type</param>
 /// <param name="value">(Required) For PlaylistType.Search - Playlist Search Term, PlaylistType.CategoriesPlaylists - Category Id, and PlaylistType.User - User Id</param>
 /// <param name="searchIsExternal">(Optional) Only for PlaylistType.Search, If true the response will include any relevant audio content that is hosted externally</param>
 public ListPlaylistViewModel(
     ISpotifySdkClient client,
     PlaylistType playlistType,
     string value          = null,
     bool?searchIsExternal = null)
     : base(client, new PlaylistsRequest()
 {
     PlaylistType     = playlistType,
     Value            = value,
     SearchIsExternal = searchIsExternal
 })
 {
 }
コード例 #29
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            LeaderboardType leaderboardType = (Session["LeaderboardType"] != null ? (LeaderboardType)Session["LeaderboardType"] : LeaderboardType.Monthly);
            PlaylistType    playlistType    = (Session["PlaylistType"] != null ? (PlaylistType)Session["PlaylistType"] : PlaylistType.Standard);

            SqlDataSource source = (leaderboardType == LeaderboardType.AllTime ? AllTimeDataSource : MonthlyDataSource);
            source.ConnectionString = Database.GetSqlConnection().ConnectionString;
            source.SelectParameters.Add("Playlist", ((int)playlistType).ToString());
            gvLeaderboard.DataSource = source;
            gvLeaderboard.DataBind();
        }
    }
コード例 #30
0
        protected SpecialPlaylistBase(IMediaLibrary library, PlaylistType type, string name)
        {
            if (library == null)
                throw new ArgumentNullException("library");
            if (type == PlaylistType.None)
                throw new ArgumentException("type");
            if (string.IsNullOrEmpty(name))
                name = type.ToString();

            m_library = library;
            m_type = type;
            m_id = library.Id + (byte)type;
            m_name = name;
        }
コード例 #31
0
 public PlaylistFilter(JToken node) : base(node)
 {
     if (node["playListTypeEqual"] != null)
     {
         this._PlayListTypeEqual = (PlaylistType)ParseEnum(typeof(PlaylistType), node["playListTypeEqual"].Value <string>());
     }
     if (node["playListTypeIn"] != null)
     {
         this._PlayListTypeIn = node["playListTypeIn"].Value <string>();
     }
     if (node["orderBy"] != null)
     {
         this._OrderBy = (PlaylistOrderBy)StringEnum.Parse(typeof(PlaylistOrderBy), node["orderBy"].Value <string>());
     }
 }
コード例 #32
0
        public async Task WritesManifestHeader(int version, PlaylistType playlistType, double targetDuration, ServerControl?serverControl, double?partDuration, Start?start, Map?map, Encryption?encryption, string expected)
        {
            var manifest = new MediaManifest(
                version,
                playlistType,
                targetDuration,
                serverControl,
                partDuration,
                start,
                map,
                encryption
                );

            Assert.Equal(expected, await RenderManifest(manifest));
        }
コード例 #33
0
        public Playlist(PlaylistType playlistType, string data)
        {
            if (playlistType != PlaylistType.XPSF &&
                playlistType != PlaylistType.M3U)
            {
                throw new NotImplementedException("Format not implemented yet.");
            }

            var playlist = playlistType == PlaylistType.XPSF
                ? (IPlaylist) new XpsfPlaylist(data)
                : (IPlaylist) new M3UPlaylist(data);

            Tracks  = playlist.Tracks;
            Type    = playlistType;
            RawData = data;
        }
コード例 #34
0
ファイル: Utils.cs プロジェクト: Namaneo/MyWindowsMediaPlayer
        public static string getFilterFromPlaylistType(PlaylistType type)
        {
            List<string> exts = new List<string>();
            switch (type)
            {
                case PlaylistType.Generic:
                    {
                        exts = Constant.Extension.Music
                            .Concat(Constant.Extension.Video)
                            .Concat(Constant.Extension.Image)
                            .ToList();
                        break;
                    }
                case PlaylistType.Music:
                    {
                        exts = Constant.Extension.Music;
                        break;
                    }
                case PlaylistType.Video:
                    {
                        exts = Constant.Extension.Video;
                        break;
                    }
                case PlaylistType.Image:
                    {
                        exts = Constant.Extension.Image;
                        break;
                    }
            }

            string parsed = "";
            foreach (string ext in exts)
            {
                parsed += ext.ToUpper() + " Files (*." + ext + ")|*." + ext + "|";
            }
            parsed = parsed.Remove(parsed.Length - 1);

            string parsedExts = "*." + string.Join(";*.", exts);
            return "All Files (" + parsedExts.Replace(";", ", ") + ")|" + parsedExts + "|" + parsed;
        }
コード例 #35
0
ファイル: XiamiDownloader.cs プロジェクト: kwedr/acdown
		protected Track[] GetPlaylist(string id, PlaylistType type)
		{
			string source = Network.GetHtmlSource(@"http://www.xiami.com/song/playlist/id/" + id + "/type/" + ((int)type).ToString(), Encoding.UTF8, Info.Proxy);
			MatchCollection matches = Regex.Matches(source, "<track>(.*?)</track>", RegexOptions.Singleline);
			List<Track> tracks = new List<Track>();
			foreach (Match item in matches) {
				string src = item.Groups[1].Value;
				Track track = new Track();
				var title = Regex.Match(src, @"<title><!\[CDATA\[(?<var>.*)\]\]></title>").Groups["var"];
				var songid = Regex.Match(src, @"<song_id>(?<var>.*)</song_id>").Groups["var"];
				track.Title = (title != null && !String.IsNullOrEmpty(title.Value) ? title.Value : "未知歌曲" + (
					(songid != null && !String.IsNullOrEmpty(songid.Value)) ? " (" + songid.Value + ")" : ""
				));
				
				var album = Regex.Match(src, @"<album_name><!\[CDATA\[(?<var>.*)\]\]></album_name>").Groups["var"];
				track.Album = (album != null && !String.IsNullOrEmpty(album.Value) ? album.Value : "(未知专辑)");
				
				var artist = Regex.Match(src, @"<artist><!\[CDATA\[(?<var>.*)\]\]></artist>").Groups["var"];
				track.Artist = (artist != null && !String.IsNullOrEmpty(artist.Value) ? artist.Value : "(未知艺术家)");
				
				var lyric = Regex.Match(src, @"<lyric>(?<var>.*)</lyric>").Groups["var"];
				if (lyric != null && !String.IsNullOrEmpty(lyric.Value))
					track.LyricURL = lyric.Value;
				
				var pic = Regex.Match(src, @"<pic>(?<var>.*)</pic>").Groups["var"];
				if (pic != null && !String.IsNullOrEmpty(pic.Value))
					track.PictureURL = pic.Value;
				
				var location = Regex.Match(src, @"<location>(?<var>.*)</location>").Groups["var"];
				if (location != null && !String.IsNullOrEmpty(location.Value))
					track.SongURL = DecodeXiamiURL (location.Value);
				
				track.Filename = track.Title + " - " + track.Album + " - " + track.Artist;
				
				tracks.Add (track);
			}
			
			return tracks.ToArray();
		}
コード例 #36
0
ファイル: PlaylistManager.cs プロジェクト: uQr/stoffi
        /// <summary>
        /// Parses a playlist and returns a collection of tracks.
        /// </summary>
        /// <param name="reader">The data stream representing the playlist</param>
        /// <param name="type">The format of the playlist</param>
        /// <param name="path">The relative path of the location of the tracks in the playlist</param>
        /// <returns>A collection of Tracks representing the tracks of the playlist</returns>
        public static ObservableCollection<TrackData> ParsePlaylist(StreamReader reader, PlaylistType type, string path = "")
        {
            switch (type)
            {
                case PlaylistType.ASX:
                    return ParseASX(reader, path);

                case PlaylistType.M3U:
                    return ParseM3U(reader, path);

                //case PlaylistType.M3U8:
                //    return ParseM3U8(reader);

                case PlaylistType.PLS:
                    return ParsePLS(reader, path);

                case PlaylistType.XSPF:
                    return ParseXSPF(reader, path);

                default:
                    throw new Exception("Unsupported playlist type: " + type);
            }
        }