Not working on Xamarin.android
See original GitHub issueHello ! I’m using the nuget package version 2.3.0 and while the library works fine in a normal console application, i cant get the library to work consistently on xamarin android,
I’m using latest xamarin.android, made an android unit test app compiling using API 25 target, and min sdk 16, running on 21 emulator( Genymotion ) using visual studio 2015 on windows 10 x64 .
I made an xamrain.android unit tester to test it after it failed in my application:
using NUnit.Framework;
using YoutubeExplode;
namespace UnitTestYoutubeExplode
{
[TestFixture]
public class TestsSample
{
public string[] ids = { "PMivT7MJ41M"};
[Test, TestCaseSource("ids")]
public async void TestMethod(string id)
{
using(var client = new YoutubeClient())
{
Assert.True(YoutubeClient.ValidateVideoId(id)); //This passed fine all the time
Assert.True(await client.CheckVideoExistsAsync(id)); //This passed fine all the time
var playlistItemInfo = await client.GetVideoInfoAsync(id);
Assert.IsNotNull(playlistItemInfo.Title);
}
}
}
}
All ids are valid.
Originally the test had more ids, but i couldn’t get it to pass even with one.
Here are the exceptions i was getting at await client.GetVideoInfoAsync(id)
:
TestMethod("h--P8HzYZ74") [FAIL] : System.Exception : Could not get video info
at YoutubeExplode.YoutubeClient+<CheckVideoExistsAsync>d__7.MoveNext () [0x000dd] in <9d4dbb3394174337b21bfdc5e06fc022>:0
TestMethod("papuvlVeZg8") [FAIL] : System.Exception : Could not get video context
at YoutubeExplode.YoutubeClient+<GetVideoInfoAsync>d__8.MoveNext () [0x000f4] in <9d4dbb3394174337b21bfdc5e06fc022>:0
TestMethod("gL-WVjvzu34") [FAIL] : System.Exception : Could not parse sts
at YoutubeExplode.Internal.Parser.VideoContextFromHtml (System.String rawHtml) [0x00066] in <9d4dbb3394174337b21bfdc5e06fc022>:0
at YoutubeExplode.YoutubeClient+<GetVideoInfoAsync>d__8.MoveNext () [0x000ff] in <9d4dbb3394174337b21bfdc5e06fc022>:0
I tried with or without reference to System.Net.Http
, different httpclient implementations (Default, Managed,AndroidClientHandler) , debug and release build and nothing make it work consistently.
About 1 in a 10 would work fine, while in the regular console application, i had no problem running 50+ one after another.
The library stated it targets .NET Standard 1.1, which xamarin.android supports, so it should work.
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Updated
Gonna push a new package on friday