Skip to content
This repository has been archived by the owner on Sep 28, 2020. It is now read-only.

Fix error 404 and changes httphelper for WP #255

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion YoutubeExtractor/YoutubeExtractor/Decipherer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal static class Decipherer
{
public static string DecipherWithVersion(string cipher, string cipherVersion)
{
string jsUrl = string.Format("http://s.ytimg.com/yts/jsbin/player-{0}.js", cipherVersion);
string jsUrl = string.Format("http://s.ytimg.com/yts/jsbin/player-{0}/base.js", cipherVersion);
string js = HttpHelper.DownloadString(jsUrl);

//Find "C" in this: var A = B.sig||C (B.s)
Expand Down
2 changes: 1 addition & 1 deletion YoutubeExtractor/YoutubeExtractor/DownloadUrlResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ private static string GetDecipheredSignature(string htmlPlayerVersion, string si

private static string GetHtml5PlayerVersion(JObject json)
{
var regex = new Regex(@"player-(.+?).js");
var regex = new Regex(@"player-(.+?)/base.js");

string js = json["assets"]["js"].ToString();

Expand Down
16 changes: 13 additions & 3 deletions YoutubeExtractor/YoutubeExtractor/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@
using System.Text;
using System.Text.RegularExpressions;


namespace YoutubeExtractor
{
internal static class HttpHelper
{
public static string DownloadString(string url)
{
#if PORTABLE
#if WINDOWS_PHONE
var request = new Windows.Web.Http.HttpMethod("GET");
var w = new Windows.Web.Http.HttpClient();

var r = await w.GetAsync(new Uri(url));
r.RequestMessage.Method = request;
r.EnsureSuccessStatusCode();
var returno = await r.Content.ReadAsStringAsync();
return returno;
#elif PORTABLE
var request = WebRequest.Create(url);
request.Method = "GET";

Expand All @@ -21,7 +31,7 @@ public static string DownloadString(string url)
null);

return task.ContinueWith(t => ReadStreamFromResponse(t.Result)).Result;
#else
#else
using (var client = new WebClient())
{
client.Encoding = System.Text.Encoding.UTF8;
Expand All @@ -32,7 +42,7 @@ public static string DownloadString(string url)

public static string HtmlDecode(string value)
{
#if PORTABLE
#if PORTABLE
return System.Net.WebUtility.HtmlDecode(value);
#else
return System.Web.HttpUtility.HtmlDecode(value);
Expand Down