Skip to content

Commit

Permalink
Use WebViewJsEngine from nuget. Version 1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tmk907 committed Sep 9, 2022
1 parent fc5446d commit 548b2bd
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 119 deletions.
2 changes: 1 addition & 1 deletion AndroidYouTubeDownloader/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tmk907.androidyoutubedownloader" android:versionCode="5" android:versionName="1.3">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.tmk907.androidyoutubedownloader" android:versionCode="6" android:versionName="1.3.1">
<application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/Theme.AndroidYouTubeDownloader"></application>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
Expand Down
7 changes: 4 additions & 3 deletions AndroidYouTubeDownloader/AndroidYouTubeDownloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<ApplicationId>com.tmk907.AndroidYouTubeDownloader</ApplicationId>
<ApplicationVersion>5</ApplicationVersion>
<ApplicationDisplayVersion>1.3</ApplicationDisplayVersion>
<ApplicationVersion>6</ApplicationVersion>
<ApplicationDisplayVersion>1.3.1</ApplicationDisplayVersion>
</PropertyGroup>

<ItemGroup>
Expand Down Expand Up @@ -36,7 +36,8 @@
<PackageReference Include="Xamarin.AndroidX.Preference" Version="1.2.0.2" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.3" />
<PackageReference Include="Xamarin.Google.Android.Material" Version="1.6.1.1" />
<PackageReference Include="YouTubeStreamsExtractor" Version="2.4.0" />
<PackageReference Include="YouTubeStreamsExtractor" Version="1.0.0" />
<PackageReference Include="YouTubeStreamsExtractor.JsEngine.AndroidWebView" Version="1.0.0" />
<PackageReference Include="z440.atl.core" Version="4.9.0" />
</ItemGroup>

Expand Down
1 change: 1 addition & 0 deletions AndroidYouTubeDownloader/DownloadFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Xamarin.Essentials;
using YouTubeStreamsExtractor.AndroidWebViewJsEngine;

namespace AndroidYouTubeDownloader
{
Expand Down
5 changes: 1 addition & 4 deletions AndroidYouTubeDownloader/Services/DownloadService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
using System.Collections.Generic;
using System.Linq;
using System.Net;
using Xamarin.Android.Net;
using Square.OkHttp;
using ATL;
using Java.Nio.FileNio.Attributes;

namespace AndroidYouTubeDownloader.Services
{
Expand All @@ -29,8 +27,7 @@ public DownloadService(Context context, YouTubeService youTubeService)
{
_context = context;
_youtubeService = youTubeService;
var handler = new AndroidClientHandler();
_httpClient = new HttpClient(handler);
_httpClient = new HttpClient();
_okHttpClient = new OkHttpClient();
}

Expand Down
51 changes: 2 additions & 49 deletions AndroidYouTubeDownloader/Services/FileService.cs
Original file line number Diff line number Diff line change
@@ -1,45 +1,11 @@
using Android.Content;
using Android.Media;
using Android.OS;
using System.IO;
using Android.Media;
using System.Threading.Tasks;
using Xamarin.Essentials;
using YouTubeStreamsExtractor;
using Environment = Android.OS.Environment;

namespace AndroidYouTubeDownloader.Services
{
public interface IFileService
public class FileService
{

string GetVideosFolderPath();
void AddMediaFile(string path);

string GetFolderPath();
}

public class FileService : IFileService
{
public string GetVideosFolderPath()
{
return Environment.GetExternalStoragePublicDirectory(Environment.DirectoryMovies).AbsolutePath;
}

public static string GetDownloadsFolderPath()
{
return Environment.GetExternalStoragePublicDirectory(Environment.DirectoryDownloads).AbsolutePath;
}

public string GetFolderPath()
{
var dir = Path.Combine(FileService.GetDownloadsFolderPath(), "YoutubeDownloads");
if (!Directory.Exists(dir))
{
Directory.CreateDirectory(dir);
}
return dir;
}

public void AddMediaFile(string path)
{
MediaScannerConnection.ScanFile(Platform.CurrentActivity.ApplicationContext, new string[] { path }, null, null);
Expand All @@ -49,19 +15,6 @@ public void AddMediaFile(string path)
//CrossCurrentActivity.Current.AppContext.SendBroadcast(intent);
}

public static string GetExtensionFromStream(IStreamInfo stream)
{
if (stream is IAudioStreamInfo)
{
if (stream.Container == "mp4")
{
return "m4a";
}
return stream.Container;
}
return stream.Container;
}

public static string RemoveForbiddenChars(string text)
{
var reservedChars = "|\\?*<\":>+[]/'";
Expand Down
3 changes: 1 addition & 2 deletions AndroidYouTubeDownloader/Services/YouTubeService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ public YouTubeService(IJavaScriptEngine javaScriptEngine)
httpClient.DefaultRequestHeaders.Add("Accept-Encoding", "gzip, deflate, br");
YouTubeStreams.ReplaceReqiredHeaders(httpClient);

_youTubeStreams = new YouTubeStreams(httpClient);
_youTubeStreams.Decryptor.ChangeJsEngine(javaScriptEngine);
_youTubeStreams = new YouTubeStreams(javaScriptEngine, httpClient);
}

public async Task<VideoDataVM> GetVideoData(string url)
Expand Down
60 changes: 0 additions & 60 deletions AndroidYouTubeDownloader/WebViewJsEngine.cs

This file was deleted.

0 comments on commit 548b2bd

Please sign in to comment.