keep track of absent album or artist tags and do not display covers for unknown albums.
This commit is contained in:
parent
915c5851f3
commit
1a6c9018e1
@ -61,6 +61,8 @@ public class MediaLibrary {
|
|||||||
public static final int ROLE_ALBUMARTIST = 2;
|
public static final int ROLE_ALBUMARTIST = 2;
|
||||||
|
|
||||||
public static final int SONG_FLAG_OUTDATED = (1 << 0); // entry in library should get rescanned.
|
public static final int SONG_FLAG_OUTDATED = (1 << 0); // entry in library should get rescanned.
|
||||||
|
public static final int SONG_FLAG_NO_ALBUM = (1 << 1); // file had no real album tag.
|
||||||
|
public static final int SONG_FLAG_NO_ARTIST = (1 << 2); // file had no real artist tag.
|
||||||
|
|
||||||
public static final String PREFERENCES_FILE = "_prefs-v1.obj";
|
public static final String PREFERENCES_FILE = "_prefs-v1.obj";
|
||||||
|
|
||||||
|
@ -509,18 +509,27 @@ public class MediaScanner implements Handler.Callback {
|
|||||||
if (mustInsert) {
|
if (mustInsert) {
|
||||||
hasChanged = true;
|
hasChanged = true;
|
||||||
|
|
||||||
|
// Clear old flags of this song:
|
||||||
|
songFlags &= ~MediaLibrary.SONG_FLAG_OUTDATED; // This file is not outdated anymore
|
||||||
|
songFlags &= ~MediaLibrary.SONG_FLAG_NO_ARTIST; // May find an artist now.
|
||||||
|
songFlags &= ~MediaLibrary.SONG_FLAG_NO_ALBUM; // May find an album now.
|
||||||
|
|
||||||
// Get tags which always must be set
|
// Get tags which always must be set
|
||||||
String title = tags.getFirst(MediaMetadataExtractor.TITLE);
|
String title = tags.getFirst(MediaMetadataExtractor.TITLE);
|
||||||
if (isUnset(title))
|
if (isUnset(title))
|
||||||
title = file.getName();
|
title = file.getName();
|
||||||
|
|
||||||
String album = tags.getFirst(MediaMetadataExtractor.ALBUM);
|
String album = tags.getFirst(MediaMetadataExtractor.ALBUM);
|
||||||
if (isUnset(album))
|
if (isUnset(album)) {
|
||||||
album = "<No Album>";
|
album = "<No Album>";
|
||||||
|
songFlags |= MediaLibrary.SONG_FLAG_NO_ALBUM;
|
||||||
|
}
|
||||||
|
|
||||||
String artist = tags.getFirst(MediaMetadataExtractor.ARTIST);
|
String artist = tags.getFirst(MediaMetadataExtractor.ARTIST);
|
||||||
if (isUnset(artist))
|
if (isUnset(artist)) {
|
||||||
artist = "<No Artist>";
|
artist = "<No Artist>";
|
||||||
|
songFlags |= MediaLibrary.SONG_FLAG_NO_ARTIST;
|
||||||
|
}
|
||||||
|
|
||||||
String discNumber = tags.getFirst(MediaMetadataExtractor.DISC_NUMBER);
|
String discNumber = tags.getFirst(MediaMetadataExtractor.DISC_NUMBER);
|
||||||
if (isUnset(discNumber))
|
if (isUnset(discNumber))
|
||||||
@ -546,7 +555,7 @@ public class MediaScanner implements Handler.Callback {
|
|||||||
v.put(MediaLibrary.SongColumns.PLAYCOUNT, playCount);
|
v.put(MediaLibrary.SongColumns.PLAYCOUNT, playCount);
|
||||||
v.put(MediaLibrary.SongColumns.SKIPCOUNT, skipCount);
|
v.put(MediaLibrary.SongColumns.SKIPCOUNT, skipCount);
|
||||||
v.put(MediaLibrary.SongColumns.PATH, path);
|
v.put(MediaLibrary.SongColumns.PATH, path);
|
||||||
v.put(MediaLibrary.SongColumns.FLAGS, (songFlags &~MediaLibrary.SONG_FLAG_OUTDATED));
|
v.put(MediaLibrary.SongColumns.FLAGS, songFlags);
|
||||||
mBackend.insert(MediaLibrary.TABLE_SONGS, null, v);
|
mBackend.insert(MediaLibrary.TABLE_SONGS, null, v);
|
||||||
|
|
||||||
v.clear();
|
v.clear();
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
* Copyright (C) 2010, 2011 Christopher Eby <kreed@kreed.org>
|
||||||
|
* Copyright (C) 2019 Adrian Ulrich <adrian@blinkenlights.ch>
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
* of this software and associated documentation files (the "Software"), to deal
|
* of this software and associated documentation files (the "Software"), to deal
|
||||||
@ -63,6 +64,7 @@ public class Song implements Comparable<Song> {
|
|||||||
MediaLibrary.SongColumns.DURATION,
|
MediaLibrary.SongColumns.DURATION,
|
||||||
MediaLibrary.SongColumns.SONG_NUMBER,
|
MediaLibrary.SongColumns.SONG_NUMBER,
|
||||||
MediaLibrary.SongColumns.DISC_NUMBER,
|
MediaLibrary.SongColumns.DISC_NUMBER,
|
||||||
|
MediaLibrary.SongColumns.FLAGS,
|
||||||
};
|
};
|
||||||
|
|
||||||
public static final String[] EMPTY_PLAYLIST_PROJECTION = {
|
public static final String[] EMPTY_PLAYLIST_PROJECTION = {
|
||||||
@ -188,6 +190,15 @@ public class Song implements Comparable<Song> {
|
|||||||
duration = cursor.getLong(7);
|
duration = cursor.getLong(7);
|
||||||
trackNumber = cursor.getInt(8);
|
trackNumber = cursor.getInt(8);
|
||||||
discNumber = cursor.getInt(9);
|
discNumber = cursor.getInt(9);
|
||||||
|
|
||||||
|
// Read and interpret the media library flags of this entry.
|
||||||
|
// There is no 1:1 mapping, so we must check each flag on its own.
|
||||||
|
int libraryFlags = cursor.getInt(10);
|
||||||
|
if ((libraryFlags & MediaLibrary.SONG_FLAG_NO_ALBUM) != 0) {
|
||||||
|
// Note that we only set, never unset: the song may already
|
||||||
|
// have the flag set for other reasons.
|
||||||
|
flags |= FLAG_NO_COVER;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user