-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #293 from zumicts/development
Development
- Loading branch information
Showing
55 changed files
with
5,047 additions
and
3,930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Audiotica.Web/Http/Requets/MatchEngine/AnyMaza/AnyMazaSearchRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Audiotica.Web.Extensions; | ||
using Audiotica.Web.Http.Requets.MatchEngine.AnyMaza.Model; | ||
|
||
namespace Audiotica.Web.Http.Requets.MatchEngine.AnyMaza | ||
{ | ||
internal class AnyMazaSearchRequest : RestObjectRequest<GoogleSearchRoot> | ||
{ | ||
public AnyMazaSearchRequest(string query) | ||
{ | ||
this.Url("https://ajax.googleapis.com/ajax/services/search/web") | ||
.QParam("q", query + " site:AnyMaza.com").QParam("v", "1.0"); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
Audiotica.Web/Http/Requets/MatchEngine/AnyMaza/Model/GoogleSearchRoot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Audiotica.Web.Http.Requets.MatchEngine.AnyMaza.Model | ||
{ | ||
public class GoogleResult | ||
{ | ||
public string GsearchResultClass { get; set; } | ||
public string UnescapedUrl { get; set; } | ||
public string Url { get; set; } | ||
public string VisibleUrl { get; set; } | ||
public string CacheUrl { get; set; } | ||
public string Title { get; set; } | ||
public string TitleNoFormatting { get; set; } | ||
public string Content { get; set; } | ||
} | ||
|
||
public class GooglePage | ||
{ | ||
public string Start { get; set; } | ||
public int Label { get; set; } | ||
} | ||
|
||
public class GoogleCursor | ||
{ | ||
public string ResultCount { get; set; } | ||
public List<GooglePage> Pages { get; set; } | ||
public string EstimatedResultCount { get; set; } | ||
public int CurrentPageIndex { get; set; } | ||
public string MoreResultsUrl { get; set; } | ||
public string SearchResultTime { get; set; } | ||
} | ||
|
||
public class GoogleSearchResponseData | ||
{ | ||
public List<GoogleResult> Results { get; set; } | ||
public GoogleCursor Cursor { get; set; } | ||
} | ||
|
||
public class GoogleSearchRoot | ||
{ | ||
public GoogleSearchResponseData ResponseData { get; set; } | ||
public object ResponseDetails { get; set; } | ||
public int ResponseStatus { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Audiotica.Web/Http/Requets/MatchEngine/MiMp3S/MiMp3SSearchRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Audiotica.Web.Extensions; | ||
using HtmlAgilityPack; | ||
|
||
namespace Audiotica.Web.Http.Requets.MatchEngine.MiMp3S | ||
{ | ||
public class MiMp3SSearchRequest : RestObjectRequest<HtmlDocument> | ||
{ | ||
public MiMp3SSearchRequest(string query) | ||
{ | ||
this.Url("http://www.mimp3s.com/{query}-mp3.html").UrlParam("query", query.Replace(" ", "-")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Audiotica.Web/Http/Requets/MatchEngine/Mp3Truck/Mp3GluSearchRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Audiotica.Web.Extensions; | ||
using HtmlAgilityPack; | ||
|
||
namespace Audiotica.Web.Http.Requets.MatchEngine.Mp3Truck | ||
{ | ||
public class Mp3GluSearchRequest : RestObjectRequest<HtmlDocument> | ||
{ | ||
public Mp3GluSearchRequest(string query) | ||
{ | ||
this.Url("http://mp3glu.com/search.php") | ||
.QParam("q", query) | ||
.Post(); | ||
} | ||
} | ||
} |
27 changes: 0 additions & 27 deletions
27
Audiotica.Web/Http/Requets/MatchEngine/Mp3Truck/Mp3TruckSearchRequest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
Audiotica.Web/MatchEngine/Providers/AnyMazaMatchProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
using Audiotica.Core.Extensions; | ||
using Audiotica.Core.Utilities.Interfaces; | ||
using Audiotica.Web.Enums; | ||
using Audiotica.Web.Extensions; | ||
using Audiotica.Web.Http.Requets.MatchEngine.AnyMaza; | ||
using Audiotica.Web.MatchEngine.Interfaces.Validators; | ||
using Audiotica.Web.Models; | ||
using HtmlAgilityPack; | ||
|
||
namespace Audiotica.Web.MatchEngine.Providers | ||
{ | ||
public class AnyMazaMatchProvider : MatchProviderBase | ||
{ | ||
public AnyMazaMatchProvider(IEnumerable<ISongTypeValidator> validators, ISettingsUtility settingsUtility) | ||
: base(validators, settingsUtility) | ||
{ | ||
} | ||
|
||
public override string DisplayName => "AnyMaza.Com"; | ||
|
||
public override ProviderSpeed Speed => ProviderSpeed.Fast; | ||
public override ProviderResultsQuality ResultsQuality => ProviderResultsQuality.Excellent; | ||
|
||
protected override async Task<List<MatchSong>> InternalGetSongsAsync(string title, string artist, int limit = 10) | ||
{ | ||
using (var resp = await new AnyMazaSearchRequest(title.Append(artist)).ToResponseAsync()) | ||
{ | ||
if (!resp.HasData) return null; | ||
|
||
var songs = new List<MatchSong>(); | ||
|
||
foreach (var googleResult in resp.Data.ResponseData.Results) | ||
{ | ||
var song = new MatchSong(); | ||
|
||
if (!googleResult.Url.StartsWith("http://anymaza.com/music/")) continue; | ||
|
||
song.SetNameAndArtistFromTitle(googleResult.TitleNoFormatting.Remove(googleResult.TitleNoFormatting.LastIndexOf(artist, StringComparison.Ordinal) + artist.Length).Replace(" By ", " - "), false); | ||
|
||
using (var anymazaResp = await googleResult.Url.ToUri().GetAsync()) | ||
{ | ||
if (!anymazaResp.IsSuccessStatusCode) continue; | ||
|
||
var document = await anymazaResp.ParseHtmlAsync(); | ||
|
||
var duration = document.DocumentNode.Descendants("center").FirstOrDefault()?.InnerText; | ||
//Category: Justin Bieber - Purpose ( Deluxe Edition ) Duration: 3:28 sec Singer : Justin Bieber | ||
if (!string.IsNullOrEmpty(duration)) | ||
{ | ||
duration = duration.Substring(duration.IndexOf("Duration:", StringComparison.Ordinal) + 9); | ||
duration = duration.Remove(duration.LastIndexOf("sec", StringComparison.Ordinal)).Trim(); | ||
TimeSpan dur; | ||
if (TimeSpan.TryParse("00:" + duration, out dur)) | ||
{ | ||
song.Duration = dur; | ||
} | ||
} | ||
|
||
var link = document.DocumentNode.Descendants("a") | ||
.FirstOrDefault(p => p.Attributes["class"]?.Value == "dowbutzip")?.Attributes["href"]?.Value; | ||
|
||
if (string.IsNullOrEmpty(link)) continue; | ||
|
||
if (link.StartsWith("/")) | ||
song.AudioUrl = "http://anymaza.com" + link; | ||
else | ||
song.AudioUrl = link; | ||
} | ||
|
||
songs.Add(song); | ||
} | ||
|
||
return songs; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.