File: clamz.h

package info (click to toggle)
clamz 0.5-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 372 kB
  • sloc: ansic: 1,941; sh: 169; makefile: 92; xml: 11
file content (120 lines) | stat: -rw-r--r-- 3,829 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
/*
 * clamz - Command-line downloader for the Amazon.com MP3 store
 * Copyright (c) 2008-2009 Benjamin Moody
 *
 * This program is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#if __GNUC__ > 2
# define UNUSED __attribute__((unused))
# define PRINTF_ARG(n,m) __attribute__((format(printf, n, m)))
#else
# define UNUSED
# define PRINTF_ARG(n,m)
#endif

/* Known playlist metadata URNs */

#define PMETA_ASIN         "http://www.amazon.com/dmusic/ASIN"
#define PMETA_GENRE        "http://www.amazon.com/dmusic/primaryGenre"

/* Track metadata URNs */

#define TMETA_ALBUM_ARTIST "http://www.amazon.com/dmusic/albumPrimaryArtist"
#define TMETA_ALBUM_ASIN   "http://www.amazon.com/dmusic/albumASIN"
#define TMETA_ASIN         "http://www.amazon.com/dmusic/ASIN"
#define TMETA_DISC_NUM     "http://www.amazon.com/dmusic/discNum"
#define TMETA_FILE_SIZE    "http://www.amazon.com/dmusic/fileSize"
#define TMETA_GENRE        "http://www.amazon.com/dmusic/primaryGenre"
#define TMETA_PRODUCT_TYPE "http://www.amazon.com/dmusic/productTypeName"
#define TMETA_TRACK_TYPE   "http://www.amazon.com/dmusic/trackType"


typedef struct _clamz_meta_list {
  char *urn;
  char *value;
  struct _clamz_meta_list *next;
} clamz_meta_list;

typedef struct _clamz_track {
  struct _clamz_playlist *playlist;

  char *location;
  char *title;
  char *creator;
  char *album;
  char *image_name;
  char *duration;
  char *trackNum;
  clamz_meta_list *meta;
} clamz_track;

typedef struct _clamz_playlist {
  char *title;
  char *creator;
  char *image_name;
  clamz_meta_list *meta;

  int num_tracks;
  clamz_track **tracks;
} clamz_playlist;

typedef struct _clamz_config {
  char *output_dir;
  char *name_format;
  char *forbid_chars;
  unsigned allowupper : 1;
  unsigned allowutf8 : 1;
  unsigned utf8locale : 1;
  unsigned printonly : 1;
  unsigned printasxml : 1;
  unsigned verbose : 1;
  unsigned quiet : 1;
  unsigned resume : 1;
  int maxattempts;
} clamz_config;

typedef struct _clamz_downloader clamz_downloader;

/* playlist.c */
int concatenate(char **str, const char *add, int len);
clamz_playlist *new_playlist();
void free_playlist(clamz_playlist *pl);
const char *find_meta(const clamz_meta_list *meta, const char *urn);
unsigned char *decrypt_amz_file(const char *b64data,
                                unsigned long b64len, const char *fname);
int read_amz_file(clamz_playlist *pl, const char *b64data,
		  unsigned long b64len, const char *fname);
int write_backup_file(const char *b64data, unsigned long b64len,
		      const char *fname);

/* options.c */
char *get_config_file_name(const char *subdir, const char *name,
			   const char *suffix);
int parse_args(int *argc, char **argv, clamz_config *cfg);

/* vars.c */
int expand_file_name(const clamz_config *cfg, const clamz_track *tr,
		     char **filename, const char *format);

/* download.c */
clamz_downloader *new_downloader(const clamz_config *cfg);
void free_downloader(clamz_downloader *dl);
void set_download_log_file(clamz_downloader *dl, FILE *log);
int download_track(clamz_downloader *dl, clamz_track *tr);

/* clamz.c */
void print_error(const char *message, ...) PRINTF_ARG(1, 2);
void print_progress(const clamz_track *tr, const char *filename,
		    int progress);