Skip to content

Commit b460c14

Browse files
s-k2cyanreg
authored andcommitted
Added an option to specify the image size for cover lookup
1 parent 3ea5055 commit b460c14

File tree

4 files changed

+36
-3
lines changed

4 files changed

+36
-3
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ Arguments are optional, except `-s`. By default cyanrip will rip all tracks from
122122
| -N | Disables MusicBrainz lookup and ignores lack of manual metadata to continue |
123123
| -A | Disables AccurateRip database query and comparison |
124124
| -U | Disables Cover art DB database query and retrieval |
125+
| -m | Lookup cover art with max size: 250, 500, 1200, -1 (no limit, default) |
125126
| -G | Disables embedding of cover art images |
126127
| | **Misc. options** |
127128
| -Q | Eject CD tray if ripping has been successfully completed |

src/coverart.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,8 @@ int crip_fill_coverart(cyanrip_ctx *ctx, int info_only)
361361
} else if (!ctx->settings.disable_coverart_db) {
362362
int has_err = 0;
363363
if (!have_front) {
364-
has_err = fetch_image(ctx, curl_ctx, &ctx->cover_arts[ctx->nb_cover_arts], release_id, "front", info_only, NULL);
364+
static const char *cover_ids[] = { "front", "front-250", "front-500", "front-1200" };
365+
has_err = fetch_image(ctx, curl_ctx, &ctx->cover_arts[ctx->nb_cover_arts], release_id, cover_ids[ctx->settings.coverart_lookup_size], info_only, NULL);
365366
if (has_err > 0) {
366367
av_dict_set(&ctx->cover_arts[ctx->nb_cover_arts].meta, "title", "Front", 0);
367368
av_dict_set(&ctx->cover_arts[ctx->nb_cover_arts].meta, "source", "Cover Art DB", 0);
@@ -370,7 +371,8 @@ int crip_fill_coverart(cyanrip_ctx *ctx, int info_only)
370371
}
371372
}
372373
if (!have_back && (has_err > 0)) {
373-
has_err = fetch_image(ctx, curl_ctx, &ctx->cover_arts[ctx->nb_cover_arts], release_id, "back", info_only, NULL);
374+
static const char *cover_ids[] = { "back", "back-250", "back-500", "back-1200" };
375+
has_err = fetch_image(ctx, curl_ctx, &ctx->cover_arts[ctx->nb_cover_arts], release_id, cover_ids[ctx->settings.coverart_lookup_size], info_only, NULL);
374376
if (has_err > 0) {
375377
av_dict_set(&ctx->cover_arts[ctx->nb_cover_arts].meta, "title", "Back", 0);
376378
av_dict_set(&ctx->cover_arts[ctx->nb_cover_arts].meta, "source", "Cover Art DB", 0);

src/cyanrip_main.c

+23-1
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ int main(int argc, char **argv)
14151415
settings.print_info_only = 0;
14161416
settings.disable_mb = 0;
14171417
settings.disable_coverart_db = 0;
1418+
settings.coverart_lookup_size = COVERART_LOOKUP_SIZE_ORIGINAL;
14181419
settings.decode_hdcd = 0;
14191420
settings.deemphasis = 1;
14201421
settings.force_deemphasis = 0;
@@ -1449,7 +1450,7 @@ int main(int argc, char **argv)
14491450
int track_cover_arts_map[198] = { 0 };
14501451
int nb_track_cover_arts = 0;
14511452

1452-
while ((c = getopt(argc, argv, "hNAUfHIVQEGWKOl:a:t:b:c:r:d:o:s:S:D:p:C:R:P:F:L:T:M:Z:")) != -1) {
1453+
while ((c = getopt(argc, argv, "hNAUfHIVQEGWKOl:a:t:b:c:r:d:o:s:S:D:p:C:R:P:F:L:T:M:Z:m:")) != -1) {
14531454
switch (c) {
14541455
case 'h':
14551456
cyanrip_log(ctx, 0, "cyanrip %s (%s) help:\n", PROJECT_VERSION_STRING, vcstag);
@@ -1485,6 +1486,7 @@ int main(int argc, char **argv)
14851486
cyanrip_log(ctx, 0, " -N Disables MusicBrainz lookup and ignores lack of manual metadata\n");
14861487
cyanrip_log(ctx, 0, " -A Disables AccurateRip database query and validation\n");
14871488
cyanrip_log(ctx, 0, " -U Disables Cover art DB database query and retrieval\n");
1489+
cyanrip_log(ctx, 0, " -m Lookup cover art with max size: 250, 500, 1200, -1 (no limit, default)\n");
14881490
cyanrip_log(ctx, 0, " -G Disables embedding of cover art images\n");
14891491
cyanrip_log(ctx, 0, "\n Misc. options:\n");
14901492
cyanrip_log(ctx, 0, " -Q Eject tray once successfully done\n");
@@ -1550,6 +1552,26 @@ int main(int argc, char **argv)
15501552
case 'U':
15511553
settings.disable_coverart_db = 1;
15521554
break;
1555+
case 'm':
1556+
long size = strtol(optarg, NULL, 10);
1557+
switch(size) {
1558+
case -1:
1559+
settings.coverart_lookup_size = COVERART_LOOKUP_SIZE_ORIGINAL;
1560+
break;
1561+
case 250:
1562+
settings.coverart_lookup_size = COVERART_LOOKUP_SIZE_250;
1563+
break;
1564+
case 500:
1565+
settings.coverart_lookup_size = COVERART_LOOKUP_SIZE_500;
1566+
break;
1567+
case 1200:
1568+
settings.coverart_lookup_size = COVERART_LOOKUP_SIZE_1200;
1569+
break;
1570+
default:
1571+
cyanrip_log(ctx, 0, "Invalid max coverart max size %i (must be 250, 500 or 1200)\n", size);
1572+
return 1;
1573+
}
1574+
break;
15531575
case 'b':
15541576
settings.bitrate = strtof(optarg, NULL);
15551577
break;

src/cyanrip_main.h

+8
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ enum CRIPSanitize {
8383
CRIP_SANITIZE_OS_UNICODE, /* Same as above, but only replaces symbols not allowed on current OS */
8484
};
8585

86+
enum coverart_lookup_sizes {
87+
COVERART_LOOKUP_SIZE_ORIGINAL = 0,
88+
COVERART_LOOKUP_SIZE_250,
89+
COVERART_LOOKUP_SIZE_500,
90+
COVERART_LOOKUP_SIZE_1200
91+
};
92+
8693
typedef struct cyanrip_settings {
8794
char *dev_path;
8895
char *folder_name_scheme;
@@ -110,6 +117,7 @@ typedef struct cyanrip_settings {
110117
int force_deemphasis;
111118
int ripping_retries;
112119
int disable_coverart_embedding;
120+
enum coverart_lookup_sizes coverart_lookup_size;
113121
int enable_replaygain;
114122

115123
enum cyanrip_output_formats outputs[CYANRIP_FORMATS_NB];

0 commit comments

Comments
 (0)