Skip to content

Commit 01929ea

Browse files
Settings page improvements (api credentials, limits)
1 parent b08625a commit 01929ea

15 files changed

+563
-64
lines changed

Images/shot04.png

-58.6 KB
Loading

Images/shot05.png

737 KB
Loading

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# YoutubeApp v1.0.40-alpha
1+
# YoutubeApp v1.0.41-alpha
22
My fork of Unofficial Youtube Client (UWP app for Desktop)
33

44
## About
@@ -8,7 +8,8 @@ The Unofficial Youtube Client is a youtube application built in UWP using the Go
88
![Win11Tiny](Images/shot01.png)
99
![Win11Tiny](Images/shot02.png)
1010
![Win11Tiny](Images/shot03.png)
11-
![W10M](Images/shot04.png)
11+
![Win11Tiny](Images/shot04.png)
12+
![W10M](Images/shot05.png)
1213

1314
## Features (the info from original readme...)
1415
- Windows Styling Integration
@@ -18,10 +19,10 @@ The Unofficial Youtube Client is a youtube application built in UWP using the Go
1819
- Download videos
1920

2021
## My 2 cents / Status
21-
- RnD (40 % complete)
22+
- RnD (41 % complete)
2223
- Min. os win sdk : 15063
23-
- VLC & VideoLib synthez started :)
24-
- GoogleAuth-on-W10M fixed (I hope!)
24+
- VLC & VideoLib synthez
25+
- GoogleAuth-on-W10M fixed
2526
- Experimental "VLCLibSharp uwp edition" library (for VS 2017 compatibility and best on-device debugging)
2627
- Hardware button back-to-main-page fixed
2728
- Flyout menu auto-hiding added
@@ -34,16 +35,16 @@ The Unofficial Youtube Client is a youtube application built in UWP using the Go
3435
- https://github.com/Saghen/UWP-Youtube-Client Liam Dyer's original Unofficial Youtube Client
3536

3637
## How to try it / fix it
37-
1. Use [Google developers console](https://console.developers.google.com/) to register your own Google Youtube API v3 items:
38+
1. Use [Google developers console](https://console.developers.google.com/) to register your own Google Youtube API v3 items (Google Youtube API Credentials):
3839
- Api key
3940
- Client Id
4041
- Client Secret
4142

42-
2. Modify that items in/at Constants.cs file
43+
2. Enter that items (Google Youtube API Credentials) at Settings page
4344

44-
3. Run the app and explore good auth, but strang video/audio deals...
45+
3. Run the app, explore video/audio deals...
4546

46-
4. Fix the bugs / improve UI
47+
4. Fix the bugs / improve UI... =)
4748

4849

4950
## ..

Src/YoutubeApp/App.xaml.cs

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using MetroLog;
22
using Newtonsoft.Json;
3+
using SharpDX;
34
using System;
45
using System.Collections.Generic;
56
using System.IO;
@@ -30,19 +31,156 @@ namespace YTApp
3031
/// </summary>
3132
sealed partial class App : Application
3233
{
34+
public static string ApiKey = "";
35+
public static string ClientID = "";
36+
public static string ClientSecret = "";
3337

38+
public static int PlaylistVideosMaxResults = 1;
39+
public static int SubscriptionsMaxResults = 1;
40+
public static int RelatedVideosMaxResults = 1;
41+
public static int SearchListRequestMaxResults = 1;
42+
public static int ChannelVideosPopularMaxResults = 1;
43+
public static int CommentsMaxResults = 1;
44+
public static int TempServiceMaxResults = 1;
3445

3546
/// <summary>
3647
/// Initializes the singleton application object. This is the first line of authored code
3748
/// executed, and as such is the logical equivalent of main() or WinMain().
3849
/// </summary>
3950
public App()
4051
{
52+
// "load" app settings *********************************************************************
53+
54+
// Theme Switch -----------------------------------
4155
if ((string)ApplicationData.Current.LocalSettings.Values["Theme"] == "Light")
4256
RequestedTheme = ApplicationTheme.Light;
4357
else
4458
RequestedTheme = ApplicationTheme.Dark;
4559

60+
// API Credentials ---------------------------------
61+
ApiKey = "";
62+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["ApiKey"] != null)
63+
{
64+
ApiKey =
65+
(string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["ApiKey"];
66+
}
67+
68+
ClientID = "";
69+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["ClientID"] != null)
70+
{
71+
ClientID =
72+
(string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["ClientID"];
73+
}
74+
75+
76+
ClientSecret = "";
77+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["ClientSecret"] != null)
78+
{
79+
ClientSecret =
80+
(string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["ClientSecret"];
81+
}
82+
83+
int result = 1;
84+
85+
// Video limits -----------------------
86+
PlaylistVideosMaxResults = 1;
87+
88+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["PlaylistVideosMaxResults"] != null)
89+
{
90+
try
91+
{
92+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["PlaylistVideosMaxResults"]);
93+
if (result < 0)
94+
result = 1;
95+
}
96+
catch (FormatException)
97+
{
98+
}
99+
PlaylistVideosMaxResults = result;
100+
}
101+
102+
SubscriptionsMaxResults = 1;
103+
104+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["SubscriptionsMaxResults"] != null)
105+
{
106+
try
107+
{
108+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["SubscriptionsMaxResults"]);
109+
if (result < 0)
110+
result = 1;
111+
}
112+
catch (FormatException)
113+
{
114+
}
115+
SubscriptionsMaxResults = result;
116+
}
117+
118+
RelatedVideosMaxResults = 1;
119+
120+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["RelatedVideosMaxResults"] != null)
121+
{
122+
try
123+
{
124+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["RelatedVideosMaxResults"]);
125+
if (result < 0)
126+
result = 1;
127+
}
128+
catch (FormatException)
129+
{
130+
}
131+
RelatedVideosMaxResults = result;
132+
}
133+
134+
SearchListRequestMaxResults = 1;
135+
136+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["SearchListRequestMaxResults"] != null)
137+
{
138+
try
139+
{
140+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["SearchListRequestMaxResults"]);
141+
if (result < 0)
142+
result = 1;
143+
}
144+
catch (FormatException)
145+
{
146+
}
147+
SearchListRequestMaxResults = result;
148+
}
149+
150+
ChannelVideosPopularMaxResults = 1;
151+
152+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["ChannelVideosPopularMaxResults"] != null)
153+
{
154+
try
155+
{
156+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["ChannelVideosPopularMaxResults"]);
157+
if (result < 0)
158+
result = 1;
159+
}
160+
catch (FormatException)
161+
{
162+
}
163+
ChannelVideosPopularMaxResults = result;
164+
}
165+
166+
TempServiceMaxResults = 1;
167+
168+
if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["TempServiceMaxResults"] != null)
169+
{
170+
try
171+
{
172+
result = Int32.Parse((string)Windows.Storage.ApplicationData.Current.LocalSettings.Values["TempServiceMaxResults"]);
173+
if (result < 0)
174+
result = 1;
175+
}
176+
catch (FormatException)
177+
{
178+
}
179+
TempServiceMaxResults = result;
180+
}
181+
182+
// *****************************************************************************************
183+
46184
this.InitializeComponent();
47185
this.Suspending += OnSuspending;
48186

Src/YoutubeApp/Classes/YoutubeMethodsStatic.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,13 @@ static async public Task<YouTubeService> GetServiceAsync()
3030
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
3131
new ClientSecrets
3232
{
33-
ClientId = Constants.ClientID,
34-
ClientSecret = Constants.ClientSecret
33+
ClientId = App.ClientID,
34+
ClientSecret = App.ClientSecret
3535
},
3636
new[]
3737
{
3838
Google.Apis.Oauth2.v2.Oauth2Service.Scope.UserinfoProfile,
39-
YouTubeService.Scope.YoutubeForceSsl
40-
//YouTubeService.Scope.Youtube
39+
YouTubeService.Scope.YoutubeForceSsl //YouTubeService.Scope.Youtube
4140
},
4241
"user",
4342
CancellationToken.None,
@@ -51,7 +50,7 @@ static async public Task<YouTubeService> GetServiceAsync()
5150
// Create the service.
5251
return new YouTubeService(new BaseClientService.Initializer()
5352
{
54-
ApiKey = Constants.ApiKey, //RnD
53+
ApiKey = App.ApiKey,
5554
HttpClientInitializer = credential,
5655
ApplicationName = Constants.ApplicationName,//"Unofficial Youtube Client",
5756
});
@@ -63,7 +62,7 @@ static public YouTubeService GetServiceNoAuth()
6362
{
6463
return new YouTubeService(new BaseClientService.Initializer()
6564
{
66-
ApiKey = Constants.ApiKey,
65+
ApiKey = App.ApiKey,
6766
ApplicationName = Constants.ApplicationName,//"Unofficial Youtube Client"
6867
});
6968
}//GetServiceNoAuth
@@ -76,8 +75,8 @@ GoogleAuthorizationCodeFlow.Initializer initializer
7675

7776
ClientSecrets secrets = new ClientSecrets
7877
{
79-
ClientId = Constants.ClientID,
80-
ClientSecret = Constants.ClientSecret
78+
ClientId = App.ClientID,
79+
ClientSecret = App.ClientSecret
8180

8281
};
8382
initializer.ClientSecrets = secrets;

Src/YoutubeApp/Constants.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,7 @@ namespace YTApp.Classes
1313
{
1414
static class Constants
1515
{
16-
static public readonly string ApplicationName =
17-
"YT Client 1";
18-
19-
static public readonly string ApiKey =
20-
"";
21-
22-
static public readonly string ClientID =
23-
"";
24-
25-
static public readonly string ClientSecret =
26-
"";
16+
static public readonly string ApplicationName = "WinBeta Videos"; // Masking YoutubeApp name :)
2717

2818
static public Google.Apis.Auth.OAuth2.Responses.TokenResponse Token;
2919

Src/YoutubeApp/MainPage.xaml.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
using Windows.Storage;
2626
using System.Threading.Tasks;
2727
using System.Diagnostics;
28-
// using YoutubeExplode;
2928

3029

3130
namespace YTApp
@@ -265,7 +264,7 @@ SubscriptionsResource.ListRequest subscriptions
265264
{
266265
subscriptions.PageToken = NextPageToken;
267266
subscriptions.Mine = true;
268-
subscriptions.MaxResults = 1;//50;
267+
subscriptions.MaxResults = App.SubscriptionsMaxResults;//50;
269268
subscriptions.Order = SubscriptionsResource.ListRequest.OrderEnum.Alphabetical;
270269

271270
return subscriptions.Execute();
@@ -300,8 +299,8 @@ public async void UpdateLoginDetails()
300299
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
301300
new ClientSecrets
302301
{
303-
ClientId = Constants.ClientID,
304-
ClientSecret = Constants.ClientSecret
302+
ClientId = App.ClientID,
303+
ClientSecret = App.ClientSecret
305304
},
306305
new[]
307306
{
@@ -436,8 +435,8 @@ private async void BtnSignOut_Tapped(object sender, RoutedEventArgs e)
436435
credential = await GoogleWebAuthorizationBroker.AuthorizeAsync(
437436
new ClientSecrets
438437
{
439-
ClientId = Constants.ClientID,
440-
ClientSecret = Constants.ClientSecret
438+
ClientId = App.ClientID,
439+
ClientSecret = App.ClientSecret
441440
}, new[]
442441
{
443442
YouTubeService.Scope.Youtube,

Src/YoutubeApp/Package.appxmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3" IgnorableNamespaces="uap mp uap3">
3-
<Identity Name="ME.YoutubeAppV1" Publisher="CN=Admin" Version="1.0.39.0" />
3+
<Identity Name="ME.YoutubeAppV1" Publisher="CN=Admin" Version="1.0.41.0" />
44
<mp:PhoneIdentity PhoneProductId="a2554722-33fb-4fd4-86a5-f9284408de31" PhonePublisherId="22000000-3311-1100-0040-800006000001" />
55
<Properties>
66
<DisplayName>YoutubeApp</DisplayName>

0 commit comments

Comments
 (0)