to show a news feed, music, sports. thanks.
private void loadfeedYoutube()
{
string feedUrl="https://gdata.youtube.com/feeds/api/standardfeeds/most_popular";
var request=new
Feed<Video> videoFeed = request.Get<Video>(new Uri(feedUrl));
printVideoFeed(videoFeed);
static void printVideoFeed(Feed<Video> feed)
{
foreach (Video entry in feed.Entries)
{
printVideoEntry(entry);
}
}
}
I'm using:
using Google.Apis.Auth.OAuth2;
using Google.Apis.Services;
using Google.Apis.Upload;
using Google.Apis.Util.Store;
using Google.Apis.YouTube.v3;
using Google.Apis.YouTube.v3.Data;
Error: not finding Feed, request...
There is using myToolkit
private void GetYoutubeChannel(string feedXML)
{
try
{
SyndicationFeed feed = new SyndicationFeed();
feed.Load(feedXML);
List<YoutubeVideo> videosList = new List<YoutubeVideo>();
YoutubeVideo video;
foreach (SyndicationItem item in feed.Items)
{
video = new YoutubeVideo();
video.YoutubeLink = item.Links[0].Uri;
string a = video.YoutubeLink.ToString().Remove(0, 31);
video.Id = a.Substring(0, 11);
video.Title = item.Title.Text;
video.PubDate = item.PublishedDate.DateTime;
video.Thumbnail = YouTube.GetThumbnailUri(video.Id, YouTubeThumbnailSize.Large);
videosList.Add(video);
}
MainListBox.ItemsSource = videosList;
}
catch { }
}
Lê Thiên Hoàng
You can try to use SyndicationFeed to help you,
check this example, which using Mytoolkit project to implement.
http://code.msdn.microsoft.com/windowsapps/Youtube-Sample-Get-Youtube-e9a3e0be
and you using feedUrl method is an old api which is v2 not v3.
#Lê Thiên Hoàng
using http://gdata.youtube.com/demo/index.html to generate you want to get.
if you want get music popular, then your RESTFul Api link is:
http://gdata.youtube.com/feeds/api/standardfeeds/most_viewed/-/{http://gdata.youtube.com/schemas/2007/categories.cat}Music?alt=rss
But I recommend if you can, using Youtube API Version3, is better and easier to get different category video.
Related
I would like to load an audio wav file in My Xamarin forms project.
The audio file is in SpeechApp=>Data=>audio.wav
I am using the Azure AudioConfig function like this:
var taskCompleteionSource = new TaskCompletionSource<int>();
var config = SpeechConfig.FromSubscription("xxx", "xx");
var transcriptionStringBuilder = new StringBuilder();
// Replace the language with your language in BCP-47 format, e.g., en-US.
var language = "fr-FR";
config.SpeechRecognitionLanguage = language;
config.OutputFormat = OutputFormat.Detailed;
using (var audioInput = AudioConfig.FromWavFileInput("SpeechApp.Data.audio.wav"))
{
using (var recognizer = new SpeechRecognizer(config, audioInput))
{
// Stops recognition.
await recognizer.StopContinuousRecognitionAsync();
}
}
But It is not working and I have this error : System.DllNotFoundException: Microsoft.CognitiveServices.Speech.core.dll
My error comes from this lines : var config = SpeechConfig.FromSubscription()
I was inspired from this web site :click here
Thanks for your help
Could you please try something like below:
using (var audioInput = AudioConfig.FromWavFileInput(#"SpeechApp.Data.audio.wav"))
{
using (var recognizer = new SpeechRecognizer(config, audioInput))
{
}
You can refer this link for more samples in different languages.
Hope it helps.
I'm trying to get value of an element at https://www.americasarmy.com/soldier/1309069 Neutralizations Deaths Ratio.
using the following code:
using (WebClient client = new WebClient())
{
try
{
client.DownloadString("https://www.americasarmy.com/soldier/1309069");
}
catch (WebException webex)
{
using (var streamReader = new StreamReader(webex.Response.GetResponseStream()))
{
ViewBag.htmlCode = streamReader.ReadToEnd();
}
}
}
if u looked at the link above then press F12 u can see all these elements but what i get when i use this code these elements so what i want is to get all the elements to get the value of Neutralizations Deaths Ratio.
This way solved what i want to get so as Jasen said it can be solve by headless browser i used phantomjs and selenium u can find both at nuget
i used the following code:
using OpenQA.Selenium;
using OpenQA.Selenium.PhantomJS;
public void Search(string url)
{
var driver = new PhantomJSDriver();
driver.Navigate().GoToUrl("url");
var DivValue = driver.FindElementByClassName("ClassName");
}
and if you want to take screenshot u can use the following code:
using System.Drawing.Imaging;
driver.GetScreenshot().SaveAsFile("test.png", ImageFormat.Png);
I'm trying to read rss feeds using Syndicationfeed class.
I have added a reference to System.servicemodel.syndication.
this is my error Project.SyndicationFeed' does not contain a definition for 'Load'
Here's my code: (console application)
using System;
using System.Xml;
using System.ServiceModel.Syndication;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string url = "http://fooblog.com/feed";
XmlReader reader = XmlReader.Create(url);
SyndicationFeed feed = new SyndicationFeed();
feed = SyndicationFeed.Load(reader);
reader.Close();
foreach (SyndicationItem item in feed.Items)
{
String subject = item.Title.Text;
String summary = item.Summary.Text;
}
}
}
}
The problem was that somehow a class SyndicationFeed.cs got added to my project which caused conflicts when calling the .Load() method.
After deleting this file from the class everything went fine.
Thanks to #user2864740 for pointing this out and leading me to the solution.
Following this link How to obtain a list of workspaces using Rally REST .NET
I tried the example however when I try to query against sub["Workspaces"] I get the error
RuntimeBinderException was unhandled;
The best overloaded method match for 'Rally.RestApi.RallyRestApi.Query(Rally.RestApi.Request)' has some invalid arguments
I cannot find any other ways to gather a list of workspaces from the subscription using the RallyApi dll for .Net which I obtained from the link provided.
Any help will be much appreciated.
Try to modify that code as follows:
Request wRequest = new Request(sub["Workspaces"]);
QueryResult queryResult = restApi.Query(wRequest);
Here is an entire app:
using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Rally.RestApi;
using Rally.RestApi.Response;
namespace Rest_v2._0_test
{
class Program
{
static void Main(string[] args)
{
//Initialize the REST API
RallyRestApi restApi;
restApi = new RallyRestApi("user#co.com", "secret", "https://rally1.rallydev.com", "v2.0");
//get the current subscription
DynamicJsonObject sub = restApi.GetSubscription("Workspaces");
Request wRequest = new Request(sub["Workspaces"]);
//query the Workspaces collection
QueryResult queryResult = restApi.Query(wRequest);
foreach (var result in queryResult.Results)
{
var workspaceReference = result["_ref"];
var workspaceName = result["Name"];
Console.WriteLine( workspaceName + " " + workspaceReference);
}
}
}
}
Iam trying to get the dht implementation of monotorrent to work but i just cant seem to find any peers.
ive tried most of the examplecode code availeble on the net like the testclient and dhttest.
I have tried with several diffrent infohashes.
Anyone here got it working? or do you know where i can find the devs?
This is how my code looks atm:
using System;
using System.Collections.Generic;
using System.Text;
using MonoTorrent.Dht;
using MonoTorrent.Dht.Listeners;
using System.Net;
using System.IO;
using MonoTorrent.Common;
using MonoTorrent.Tracker.Listeners;
namespace SampleClient
{
class Program
{
static void Main(string[] args)
{
string basePath = Environment.CurrentDirectory;
string torrentsPath = Path.Combine(basePath, "Torrents");
Torrent torrent = null;
// If the torrentsPath does not exist, we want to create it
if (!Directory.Exists(torrentsPath))
Directory.CreateDirectory(torrentsPath);
// For each file in the torrents path that is a .torrent file, load it into the engine.
foreach (string file in Directory.GetFiles(torrentsPath))
{
if (file.EndsWith(".torrent"))
{
try
{
// Load the .torrent from the file into a Torrent instance
// You can use this to do preprocessing should you need to
torrent = Torrent.Load(file);
Console.WriteLine(torrent.InfoHash.ToString());
}
catch (Exception e)
{
Console.Write("Couldn't decode {0}: ", file);
Console.WriteLine(e.Message);
continue;
}
}
}
DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000));
DhtEngine engine = new DhtEngine(listener);
//engine.RegisterDht(dht);
byte[] nodes = null;
if (File.Exists("mynodes"))
nodes = File.ReadAllBytes("mynodes");
listener.Start();
int i = 0;
bool running = true;
StringBuilder sb = new StringBuilder(1024);
while (running)
{
engine.Start(nodes);
while (Console.ReadLine() != "q")
{
engine.GetPeers(torrent.InfoHash);
}
File.WriteAllBytes("mynodes", engine.SaveNodes());
}
}
}
}
I know it's very old question, I'm not sure why it's still noone has answer it, anyway. The problem seem to be this line:
DhtListener listener = new DhtListener(new IPEndPoint(IPAddress.Parse("192.168.2.3"), 10000));
This ip is not the real ip, so you actually asl peers to send the respone to unkonw adress.
What to do? register your own adress.