Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Further fixes to playlists, thumb gen
Browse files Browse the repository at this point in the history
  • Loading branch information
gfrn committed Dec 20, 2020
1 parent 308efd7 commit 62d194d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 25 deletions.
2 changes: 1 addition & 1 deletion WPFMETRO/Localization/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion WPFMETRO/Localization/Strings.pt-BR.resx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
<value>Para aplicar as mudanças de idioma, reinicie o programa</value>
</data>
<data name="RetrievingFormats" xml:space="preserve">
<value>Buscando Formatos...</value>
<value>Buscando Dados...</value>
</data>
<data name="SaveChanges" xml:space="preserve">
<value>Salvar</value>
Expand Down
2 changes: 1 addition & 1 deletion WPFMETRO/Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
<value>Restart the program to apply language changes</value>
</data>
<data name="RetrevingFormats" xml:space="preserve">
<value>Retrieving Formats...</value>
<value>Retrieving Video Metadata...</value>
</data>
<data name="SaveChanges" xml:space="preserve">
<value>Save Changes</value>
Expand Down
8 changes: 6 additions & 2 deletions WPFMETRO/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ private bool IsRunningAsAdmin()

private async void SelectButton_Click(object sender, RoutedEventArgs e)
{
DownloadStatus.Text = Localization.Strings.RetrevingFormats;
UrlBox.Background = Brushes.Transparent;
formats.Clear();
string Url = UrlBox.Text;
Expand All @@ -145,11 +146,12 @@ private async void SelectButton_Click(object sender, RoutedEventArgs e)
FiletypeBox.ItemsSource = formats;
FiletypeBox.IsEnabled = AddToQueueButton.IsEnabled = true;
UrlBox.Background = Brushes.DarkGreen;


}
else
{
UrlBox.Text = UrlBox.Text.Contains(@"&list=") ? UrlBox.Text.Substring(0, UrlBox.Text.IndexOf(@"&list=")) : UrlBox.Text;
DownloadStatus.Text = Localization.Strings.RetrevingFormats;

await Task.Run(() => formats=queue.GetFormats(Url));
await Task.Run(() => videoInfo=queue.GetInfo(Url));
Expand Down Expand Up @@ -284,7 +286,9 @@ public void UpdateCard()

if (video.ThumbURL != null)
{
var imageData = new WebClient().DownloadData(new Uri(video.ThumbURL + ".jpg"));
string extension = video.ThumbURL.Substring(video.ThumbURL.LastIndexOf("."));
video.ThumbURL = extension == ".jpg" ? video.ThumbURL : video.ThumbURL + ".jpg";
var imageData = new WebClient().DownloadData(new Uri(video.ThumbURL));
var bitmapImage = new BitmapImage { CacheOption = BitmapCacheOption.OnLoad };
bitmapImage.BeginInit();
bitmapImage.StreamSource = new MemoryStream(imageData);
Expand Down
4 changes: 2 additions & 2 deletions WPFMETRO/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.5.0.6")]
[assembly: AssemblyFileVersion("1.5.0.6")]
[assembly: AssemblyVersion("1.5.0.7")]
[assembly: AssemblyFileVersion("1.5.0.7")]
20 changes: 2 additions & 18 deletions WPFMETRO/Queue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public Dictionary<string, string> GetFormats(string url)
{
output = f.Data ?? "null";

if (output != "null")
if (output != "null" && !output.Contains("["))
{
if (isNext)
{
Expand Down Expand Up @@ -172,23 +172,7 @@ public void DownloadPlaylist(string ID, string filename, string path, string fil

foreach (var playlistItem in playlistItemsListResponse.Items)
{
var videoRequest = yt.Videos.List("snippet,status");

videoRequest.Id = playlistItem.Id;

var videoListResponse = videoRequest.Execute();

if (videoListResponse.Items.Count < 1)
{
throw new QueueException(Localization.Strings.InvalidURL);
}
foreach (var videoItem in videoListResponse.Items)
{
if (videoItem.Status != null)
{
ModifyQueue(videoItem.Snippet.Title, videoItem.Snippet.Thumbnails.Default__.Url, "https://www.youtube.com/watch?v=" + playlistItem.Snippet.ResourceId.VideoId, filename, path, filetype, formats);
}
}
ModifyQueue(playlistItem.Snippet.Title, playlistItem.Snippet.Thumbnails.Default__.Url, "https://www.youtube.com/watch?v=" + playlistItem.Snippet.ResourceId.VideoId, filename, path, filetype, formats);
}

nextPageToken = playlistItemsListResponse.NextPageToken;
Expand Down

0 comments on commit 62d194d

Please sign in to comment.