Skip to content

Commit

Permalink
Switch from Array to List
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry08 committed Sep 1, 2023
1 parent eeaaff5 commit cdb3908
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion SoundCloudExplode/Playlists/Playlist.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json.Serialization;
using SoundCloudExplode.Common;
Expand Down Expand Up @@ -103,7 +104,7 @@ public class Playlist : IBatchItem
public PlaylistUser? User { get; set; }

[JsonPropertyName("tracks")]
public Track[]? Tracks { get; set; }
public List<Track> Tracks { get; set; } = new();

[JsonPropertyName("track_count")]
public long? TrackCount { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions SoundCloudExplode/Playlists/PlaylistClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public async ValueTask<Playlist> GetAsync(
if (populateAllTracks)
{
var tracks = await GetTracksAsync(url, cancellationToken: cancellationToken);
playlist.Tracks = tracks.ToArray();
playlist.Tracks = tracks.ToList();

foreach (var track in playlist.Tracks)
track.PlaylistName = playlist.Title;
Expand All @@ -113,7 +113,7 @@ public async IAsyncEnumerable<Batch<Track>> GetTrackBatchesAsync(
yield break;

if (offset > 0)
playlist.Tracks = playlist.Tracks.Skip(offset).ToArray();
playlist.Tracks = playlist.Tracks.Skip(offset).ToList();

// Soundcloud single request limit is 50
foreach (var chunk in playlist.Tracks.ChunkBy(50))
Expand Down
5 changes: 3 additions & 2 deletions SoundCloudExplode/Playlists/Visuals.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace SoundCloudExplode.Playlists;

Expand All @@ -11,7 +12,7 @@ public class Visuals
public bool Enabled { get; set; }

[JsonPropertyName("visuals")]
public Visual[]? Items { get; set; }
public List<Visual> Items { get; set; } = new();

[JsonPropertyName("tracking")]
public object? Tracking { get; set; }
Expand Down
5 changes: 3 additions & 2 deletions SoundCloudExplode/Tracks/Media.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
using System.Text.Json.Serialization;
using System.Collections.Generic;
using System.Text.Json.Serialization;

namespace SoundCloudExplode.Tracks;

public class Media
{
[JsonPropertyName("transcodings")]
public Transcoding[]? Transcodings { get; set; }
public List<Transcoding> Transcodings { get; set; } = new();
}
2 changes: 1 addition & 1 deletion SoundCloudExplode/Tracks/TrackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public async Task<bool> IsUrlValidAsync(

if (track.Media is null
|| track.Media.Transcodings is null
|| track.Media.Transcodings.Length == 0)
|| track.Media.Transcodings.Count == 0)
{
throw new TrackUnavailableException("No transcodings found");
}
Expand Down
3 changes: 2 additions & 1 deletion SoundCloudExplode/Users/PlaylistUser.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
using SoundCloudExplode.Playlists;

Expand All @@ -22,7 +23,7 @@ public class PlaylistUser
public DateTimeOffset? CreatedAt { get; set; }

[JsonPropertyName("creator_subscriptions")]
public CreatorSubscription[]? CreatorSubscriptions { get; set; }
public List<CreatorSubscription> CreatorSubscriptions { get; set; } = new();

[JsonPropertyName("creator_subscription")]
public CreatorSubscription? CreatorSubscription { get; set; }
Expand Down

0 comments on commit cdb3908

Please sign in to comment.