Skip to content

Commit 352b2d3

Browse files
committed
1 parent 1cec92e commit 352b2d3

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

API.pm

+5-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ sub getImageUrl {
114114
sub typeOfItem {
115115
my ($class, $item) = @_;
116116

117+
return '' unless ref $item;
118+
117119
if ( $item->{type} && $item->{type} =~ /(?:EXTURL|VIDEO)/ ) {}
118120
elsif ( defined $item->{hasPlaylists} && $item->{path} ) {
119121
return 'category';
@@ -153,7 +155,9 @@ sub cacheTrackMetadata {
153155
my $entry = $_;
154156
$entry = $entry->{item} if $entry->{item};
155157

156-
my $oldMeta = $cache->get( 'tidal_meta_' . $entry->{id}) || {};
158+
my $oldMeta = $cache->get( 'tidal_meta_' . $entry->{id});
159+
$oldMeta = {} unless ref $oldMeta;
160+
157161
my $icon = $class->getImageUrl($entry, 'usePlaceholder', 'track');
158162
my $artist = $entry->{artist};
159163
($artist) = grep { $_->{type} eq 'MAIN'} @{$entry->{artists}} unless $artist;

API/Async.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ sub getFavorites {
455455

456456
# use cached data unless the collection has changed
457457
my $cached = $cache->get($cacheKey);
458-
if ($cached && ref $cached->{items}) {
458+
if (ref $cached && ref $cached->{items}) {
459459
# don't bother verifying timestamp unless we're sure we need to
460460
return $cb->($cached->{items}) unless $refresh;
461461

@@ -517,7 +517,7 @@ sub getCollectionPlaylists {
517517
};
518518

519519
my $cached = $cache->get($cacheKey);
520-
if ($cached && ref $cached->{items}) {
520+
if (ref $cached && ref $cached->{items}) {
521521
return $cb->($cached->{items}) unless $refresh;
522522

523523
$self->getLatestCollectionTimestamp(sub {

Importer.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ sub scanAlbums { if (main::SCANNER) {
7070
foreach my $album (@$albums) {
7171
my $albumDetails = $cache->get('tidal_album_with_tracks_' . $album->{id});
7272

73-
if ( $albumDetails && $albumDetails->{tracks} && ref $albumDetails->{tracks}) {
73+
if ( ref $albumDetails && $albumDetails->{tracks} && ref $albumDetails->{tracks}) {
7474
$progress->update($album->{title});
7575

7676
$class->storeTracks([

InfoMenu.pm

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ sub _menuTrackInfo {
439439

440440
# if we are here, the metadata of the track is cached
441441
my $track = $cache->get("tidal_meta_$id");
442-
$log->error("metadata not cached for $id") && return [] unless $track;
442+
$log->error("metadata not cached for $id") && return [] unless $track && ref $track;
443443

444444
# play/add/add_next options except for skins that don't want it
445445
my $base = _menuBase($api->client, 'track', $id, $params);

ProtocolHandler.pm

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ sub trackGain {
6363
my $trackId = getId($url);
6464
my $meta = $cache->get( 'tidal_meta_' . ($trackId || '') );
6565

66-
return unless $meta && defined $meta->{replay_gain} && defined $meta->{peak};
66+
return unless ref $meta && defined $meta->{replay_gain} && defined $meta->{peak};
6767

6868
# TODO - try to get album gain information?
6969

@@ -260,7 +260,7 @@ sub getMetadataFor {
260260
my $meta = $cache->get( 'tidal_meta_' . ($trackId || '') );
261261

262262
# if metadata is in cache, we just need to add bitrate
263-
if ($meta) {
263+
if (ref $meta) {
264264
# TODO - remove if we decide to move to our own cache file which we can version
265265
$meta->{artist} = $meta->{artist}->{name} if ref $meta->{artist};
266266

0 commit comments

Comments
 (0)