Skip to content

Commit

Permalink
added workaround for Plex' missing metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
memen45 committed Oct 19, 2022
1 parent 6493209 commit 520c2ae
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 12 deletions.
3 changes: 3 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Version [] -

Version [0.2.6] - 19-10-2022
- added workaround for Plex' missing metadata

Version [0.2.5] - 16-10-2022
- fixed Plex sync error with larger playlists

Expand Down
2 changes: 1 addition & 1 deletion manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<!-- This is a generated file. It is highly recommended that you DO NOT edit this file. -->
<iq:manifest xmlns:iq="http://www.garmin.com/xml/connectiq" version="3">
<iq:application entry="SubMusicApp" id="62436b93f69e4823a8b41854b6684b4a" launcherIcon="@Drawables.LauncherIcon" name="@Strings.AppName" type="audio-content-provider-app" version="0.2.5">
<iq:application entry="SubMusicApp" id="62436b93f69e4823a8b41854b6684b4a" launcherIcon="@Drawables.LauncherIcon" name="@Strings.AppName" type="audio-content-provider-app" version="0.2.6">
<iq:products>
<iq:product id="d2air"/>
<iq:product id="d2airx10"/>
Expand Down
4 changes: 2 additions & 2 deletions source/Api/AmpacheProvider.mc
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ class AmpacheProvider {
}
d_response.add(new Song({
"id" => song["id"],
"title" => song["title"],
"artist" => song["artist"]["name"],
// "title" => song["title"],
// "artist" => song["artist"]["name"],
"time" => time.toNumber(),
"mime" => song["mime"],
"art_id" => song["id"],
Expand Down
4 changes: 2 additions & 2 deletions source/Api/SubsonicProvider.mc
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ class SubsonicProvider {
}
songs.add(new Song({
"id" => song["id"],
"title" => song["title"],
"artist" => song["artist"],
// "title" => song["title"],
// "artist" => song["artist"],
"time" => time.toNumber(),
"mime" => song["contentType"],
"art_id" => song["coverArt"],
Expand Down
8 changes: 8 additions & 0 deletions source/Audio.mc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ class Audio extends Storable {
return d_audio.artwork();
}

function title() {
return d_audio.title();
}

function artist() {
return d_audio.artist();
}

function time() {
return d_audio.time();
}
Expand Down
5 changes: 5 additions & 0 deletions source/Episode.mc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Episode extends Storable {
// required external episode properties
"id" => null, // id of the episode
"title" => "", // title of the episode
"artist" => "", //
"time" => 0, // duration of the episode
"mime" => "", // string e.g. "audio/mpeg"
"art_id" => null, // null if no art_id available
Expand All @@ -30,6 +31,10 @@ class Episode extends Storable {
function title() {
return d_storage["title"];
}

function artist() {
return d_storage["artist"];
}

function time() {
return d_storage["time"];
Expand Down
4 changes: 2 additions & 2 deletions source/Song.mc
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ class ISong extends Song {
// update the variables
var changed = updateAny("time", song.time());
changed |= updateAny("mime", song.mime());
// changed |= updateAny("title", song.title()); // not used, so no storage needed
// changed |= updateAny("artist", song.artist()); // not used, so no storage needed
changed |= updateAny("title", song.title()); // not used, so no storage needed
changed |= updateAny("artist", song.artist()); // not used, so no storage needed
changed |= setArt_id(song.art_id());
if (changed) {
save();
Expand Down
10 changes: 10 additions & 0 deletions source/SubMusicContentIterator.mc
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ class SubMusicContentIterator extends Media.ContentIterator {
var content = Media.getCachedContentObj(contentRef);
var metadata = content.getMetadata();

// add stored metadata if not given in file (Plex does not provide metadata in file)
var has_title = (metadata.title != null) && (metadata.title instanceof Lang.String) && (!metadata.title.equals(""));
var has_artist = (metadata.artist != null) && (metadata.artist instanceof Lang.String) && (!metadata.artist.equals(""));
if (!has_title) {
metadata.title = audio.title();
}
if (!has_artist) {
metadata.artist = audio.artist();
}

// default playback is 0, unless in podcast mode, some position is stored before and position is not within five seconds of the end
var playbackStartPos = 0;
if (d_playable.podcast_mode()
Expand Down
4 changes: 2 additions & 2 deletions source/SubMusicVersion.mc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ class SubMusicVersion {

private var d_major = 0;
private var d_minor = 2;
private var d_patch = 5;
private var d_name = "argalus";
private var d_patch = 6;
private var d_name = "kynortas";

function initialize(storage) {
if (storage == null) {
Expand Down
18 changes: 15 additions & 3 deletions source/View/SubMusicMenuSongsLocal.mc
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,22 @@ module SubMusic {
// load the menuitem
var id = d_ids[idx];
var isong = new ISong(id);
var meta = isong.metadata();
var metadata = isong.metadata();

// add stored metadata if not given in file (Plex does not provide metadata in file)
var has_title = (metadata.title != null) && (metadata.title instanceof Lang.String) && (!metadata.title.equals(""));
var has_artist = (metadata.artist != null) && (metadata.artist instanceof Lang.String) && (!metadata.artist.equals(""));
if (!has_title) {
metadata.title = isong.title();
}
if (!has_artist) {
metadata.artist = isong.artist();
}

// add the item
items.add({
LABEL => meta.title,
SUBLABEL => meta.artist,
LABEL => metadata.title,
SUBLABEL => metadata.artist,
METHOD => id,
// OPTION => isong.artwork(),
});
Expand Down

0 comments on commit 520c2ae

Please sign in to comment.