public List <ArtistItem> GetSimilarArtistsSite(string site) { List <ArtistItem> res = new List <ArtistItem>(); try { Regex regexObj = new Regex("<h3 class=\"channel-summary-title\">.*?<a href=\"/artist/(?<id>.*?)\" class=\"yt-uix-tile-link\">YouTube - (?<name>.*?)</a>", RegexOptions.Singleline); Match matchResult = regexObj.Match(site); while (matchResult.Success) { ArtistItem item = new ArtistItem() { Id = matchResult.Groups["id"].Value, Name = HttpUtility.HtmlDecode(matchResult.Groups["name"].Value) }; ArtistManager.Instance.AddArtist(item); res.Add(item); matchResult = matchResult.NextMatch(); } } catch (ArgumentException ex) { // Syntax error in the regular expression } return(res); }
private async Task <string> GetTokenFromIndus() { DP_TPEntities db = new DP_TPEntities(); string uri = "https://fastag.gitechnology.in/indusindAPI/api/Authentication/RequestToken"; var client = new RestClient(uri); client.Timeout = -1; var request = new RestRequest(Method.GET); string nonce = OAuthBase.GenerateNonce(); string timeStamp = OAuthBase.GenerateTimeStamp(); string sig = OAuthBase.GenerateSignature(new Uri(uri), Consumerkey, ConsumerSecret, null, null, "GET", timeStamp, nonce, OAuthBase.HMACSHA1SignatureType); sig = HttpUtility.UrlEncode(sig); string authString = String.Format(@"OAuth oauth_consumer_key=""{0}"",oauth_signature_method=""HMAC-SHA1"",oauth_timestamp=""{1}"",oauth_nonce=""{2}"",oauth_version=""1.0"",oauth_signature=""{3}""""", Consumerkey, timeStamp, nonce, sig); request.AddHeader("Authorization", authString); request.AddHeader("Connection", "Keep-Alive"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); TokenResponse json = JsonConvert.DeserializeObject <TokenResponse>(response.Content); var x = json.ResponseData;// this extracts the encrypted requesttoken; string s1 = EncryptionsUtility.AES_DECRYPT(x, AESkey); clsTokenResponse obj = JsonConvert.DeserializeObject <clsTokenResponse>(s1); Console.WriteLine(obj.ResponseContent.Token); db.IndusInd_Token_Secrete.Add(new IndusInd_Token_Secrete() { CreateDate = DateTime.Now, Token = obj.ResponseContent.Token, TokenSecrete = obj.ResponseContent.TokenSecret }); db.SaveChanges(); return(s1); }
public static string getheader(string strurl, string methodtype) { string nonce = OAuthBase.GenerateNonce(); string timeStamp = OAuthBase.GenerateTimeStamp(); DP_TPEntities db = new DP_TPEntities(); IndusInd_Token_Secrete lastestts = db.IndusInd_Token_Secrete.ToList().LastOrDefault(); string sig = OAuthBase.GenerateSignature(new Uri(strurl), Consumerkey, ConsumerSecret, lastestts.Token, lastestts.TokenSecrete, methodtype, timeStamp, nonce, OAuthBase.HMACSHA1SignatureType); sig = HttpUtility.UrlEncode(sig); string authString2 = String.Format(@"OAuth oauth_consumer_key=""{0}"",oauth_nonce=""{1}"",oauth_signature=""{2}"",oauth_signature_method=""HMAC-SHA1"",oauth_timestamp=""{3}"",oauth_token=""{4}"",oauth_version=""1.0""", Consumerkey, nonce, sig, timeStamp, lastestts.Token); return(authString2); }
public ArtistItem GetFromVideoSite(string site) { ArtistItem res = new ArtistItem(); try { Regex regexObj = new Regex(@"<a href=""/artist/(?<id>.*?)\?.*?Artist: <span class=.link-like.>(?<name>.*?)</span>", RegexOptions.Singleline); Match matchResult = regexObj.Match(site); while (matchResult.Success) { res.Id = matchResult.Groups["id"].Value; res.Name = HttpUtility.HtmlDecode(matchResult.Groups["name"].Value); //res.Img_url = HttpUtility.HtmlDecode(matchResult.Groups["img_url"].Value); matchResult = matchResult.NextMatch(); } GetArtistUser(res.Id); } catch (ArgumentException ex) { // Syntax error in the regular expression } return(res); }
public GenericListItemCollections GetArtistVideosIds(string artist_name) { string site = DownloadArtistInfo(artist_name); GetSimilarArtistsSite(site); string playlist_id = null; try { Regex regexObj = new Regex("data-list_id=\"(?<name>.*?)\"", RegexOptions.Singleline); playlist_id = regexObj.Match(site).Groups["name"].Value; } catch (ArgumentException ex) { // Syntax error in the regular expression } site = DownloadString(string.Format("http://www.youtube.com/playlist?list={0}", playlist_id)); GenericListItemCollections res = new GenericListItemCollections(); try { //------------------------------ //string img = Regex.Match(site, "<img class=\"artist-image\" src=\"(?<url>.*?)\" />", RegexOptions.Singleline).Groups["url"].Value; //ArtistItem artistItem = ArtistManager.Instance.GetArtistsById(artist_id); //artistItem.Img_url = img; //ArtistManager.Instance.Save(artistItem); //---------------------------- //@"<li class=""playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>" //Regex regexObj = new Regex("album-row.*?data-video-ids=\"(?<vid_id>.*?)\".*?<span class=\"clip\"><img src=\"(?<thumb>.*?)\".*?album-track-name\">(?<title>.*?)</span>", RegexOptions.Singleline); Regex regexObj = new Regex(@"playlist-video-item.*?<a href=""/watch\?v=(?<vid_id>.*?)&.*?data-thumb=""(?<thumb>.*?)"".*?<span class=""video-time"">(?<duration>.*?)</span>.*?video-title "" dir=""ltr"">(?<title>.*?)</span>", RegexOptions.Singleline); Match matchResult = regexObj.Match(site); while (matchResult.Success) { YouTubeEntry youTubeEntry = new YouTubeEntry(); youTubeEntry.AlternateUri = new AtomUri("http://www.youtube.com/watch?v=" + matchResult.Groups["vid_id"].Value); youTubeEntry.Title = new AtomTextConstruct(); youTubeEntry.Title.Text = HttpUtility.HtmlDecode(matchResult.Groups["title"].Value); youTubeEntry.Media = new MediaGroup(); youTubeEntry.Media.Description = new MediaDescription(""); youTubeEntry.Id = new AtomId(youTubeEntry.AlternateUri.Content); GenericListItem listItem = new GenericListItem() { Title = youTubeEntry.Title.Text, IsFolder = false, LogoUrl = "http:" + matchResult.Groups["thumb"].Value.Replace("default.jpg", "hqdefault.jpg"), Tag = youTubeEntry, Title2 = matchResult.Groups["duration"].Value, //ParentTag = artistItem }; res.Items.Add(listItem); //resultList.Add(matchResult.Groups["groupname"].Value); matchResult = matchResult.NextMatch(); } } catch (Exception ex) { // Syntax error in the regular expression } res.ItemType = ItemType.Video; return(res); }