Пример #1
0
 public static string UrlPlaylistByIdAndType(string id, EnumMusicType type)
 {
     return url_type_id.WithParams(new Dictionary<string, string>{
         {"id",id},
         {"type",type.ToString()}
     });
 }
Пример #2
0
 public static string UrlSearch(string key, int page, EnumMusicType type)
 {
     return url_search_all.WithParams(new Dictionary<string, string>
     {
         {"key",key},
         {"type",type.ToString()+"s"},
         {"page",page.ToString()}
     });
 }
Пример #3
0
 public static string UrlSearch(string key, int page, EnumMusicType type)
 {
     return(url_search_all.WithParams(new Dictionary <string, string>
     {
         { "key", key },
         { "type", type.ToString() + "s" },
         { "page", page.ToString() }
     }));
 }
    async static Task <SearchResult> _searchByKey(string keyword, int page, EnumMusicType type = EnumMusicType.song)
    {
        dynamic obj = await NetAccess.Json(XiamiUrl.url_search_all, "key", keyword, "page", page.ToString());

        /////////////
        if (obj == null)
        {
            return(null);
        }
        //string typestr = type.ToString();
        //dynamic obj = await XiamiClient.GetDefault().Call_xiami_api(string.Format("Search.{0}s", typestr),
        //    string.Format("\"key={0}\"", keyword),
        //    string.Format("page={0}", page));
        //if (obj == null) return null;
        dynamic data = obj[type.ToString() + "s"];

        if (data == null)
        {
            return(null);
        }
        var items = new List <IMusic>();

        foreach (dynamic x in data)
        {
            items.Add(MusicFactory.CreateFromJson(x, type));
        }
        var searchType = EnumSearchType.song;

        Enum.TryParse <EnumSearchType>(type.ToString(), out searchType);
        bool hasNext = page.ToString() != obj["next"];
        var  res     = new SearchResult
        {
            Items      = items,
            Keyword    = keyword,
            Page       = page,
            HasNext    = hasNext,
            SearchType = searchType,
        };

        return(res);
    }
 async static Task<SearchResult> _searchByKey(string keyword, int page, EnumMusicType type = EnumMusicType.song)
 {
     dynamic obj = await NetAccess.Json(XiamiUrl.url_search_all, "key", keyword, "page", page.ToString());
     /////////////
     if (obj == null) return null;
     //string typestr = type.ToString();
     //dynamic obj = await XiamiClient.GetDefault().Call_xiami_api(string.Format("Search.{0}s", typestr),
     //    string.Format("\"key={0}\"", keyword),
     //    string.Format("page={0}", page));
     //if (obj == null) return null;
     dynamic data = obj[type.ToString() + "s"];
     if (data == null) return null;
     var items = new List<IMusic>();
     foreach (dynamic x in data)
     {
         items.Add(MusicFactory.CreateFromJson(x, type));
     }
     var searchType = EnumSearchType.song;
     Enum.TryParse<EnumSearchType>(type.ToString(), out searchType);
     bool hasNext = page.ToString() != obj["next"];
     var res = new SearchResult
     {
         Items = items,
         Keyword = keyword,
         Page = page,
         HasNext = hasNext,
         SearchType = searchType,
     };
     return res;
 }
Пример #6
0
        public static async Task GetSongOfType(string id, EnumMusicType type)
        {
            if (string.IsNullOrEmpty(id)) return;
			var key=string.Format("http://www.xiami.com/type/{0}/id/{1}",type.ToString(),id);
			await Search(key);
        }