示例#1
0
        private async Task Search()
        {
            foreach (var musicApi in MusicApis)
            {
                var result = await musicApi.CheckForSpecialUrl(SearchText);

                if (result.Item1)
                {
                    SortResults(result.Item2);
                    PlaylistResult = result.Item3;
                    return;
                }
            }
            var list = new List <WebTrackResultBase>();

            var tasks = MusicApis.Where((t, i) => _manager.DownloadManager.SelectedService == 0 || _manager.DownloadManager.SelectedService == i + 1).Select(t => t.Search(SearchText)).ToList();

            foreach (var task in tasks)
            {
                list.AddRange(await task);
            }

            NothingFound = list.Count == 0;
            SortResults(list);
            var str = _manager.DownloadManager.Searches.FirstOrDefault(x => x.ToUpper() == SearchText.ToUpper());

            if (!string.IsNullOrEmpty(str))
            {
                _manager.DownloadManager.Searches.Move(_manager.DownloadManager.Searches.IndexOf(str), 0);
            }
            else
            {
                _manager.DownloadManager.Searches.Insert(0, SearchText);
            }
        }
示例#2
0
        private async Task Search()
        {
            _currentPageIndex++;
            if (SearchText.Contains("http"))
            {
                if (_currentPageIndex > 1)
                {
                    return;
                }
                foreach (var musicApi in MusicApis.Where(x => x.IsEnabled))
                {
                    var result = await musicApi.CheckForSpecialUrl(SearchText);

                    if (!result.Item1)
                    {
                        continue;
                    }
                    SortResults(result.Item2);
                    PlaylistResult = result.Item3;
                    return;
                }
            }
            var list = new List <WebTrackResultBase>();

            if (_currentPageIndex > 1)
            {
                list.AddRange(Results);
            }
            var count = list.Count;
            var tasks = MusicApis.Where((t, i) => t.IsEnabled && (_manager.DownloadManager.SelectedService == 0 || _manager.DownloadManager.SelectedService == i + 1)).Select(t => t.Search(SearchText, _currentPageIndex, 30)).ToList();

            foreach (var task in tasks)
            {
                var results = await task;
                if (results != null)
                {
                    list.AddRange(results);
                }
            }
            HasNext      = list.Count > count;
            NothingFound = list.Count == 0;
            SortResults(list);
            var str = _manager.DownloadManager.Searches.FirstOrDefault(x => x.ToUpper() == SearchText.ToUpper());

            if (!string.IsNullOrEmpty(str))
            {
                _manager.DownloadManager.Searches.Move(_manager.DownloadManager.Searches.IndexOf(str), 0);
            }
            else
            {
                _manager.DownloadManager.Searches.Insert(0, SearchText);
            }
        }