updated on Sun Jan 15 08:01:04 UTC 2012
[aur-mirror.git] / mp3rename / combined-mp3rename_0.6.9-and-jf-archlinux-and-jf-manpage-and-jf-padnumbers.diff
blob397fbe586e6f491591007fd6f52c53640e44282c
1 --- mp3rename-0.6/mp3rename.c
2 +++ mp3rename-0.6/mp3rename.c 2007-05-17 05:20:02.000000000 +0200
3 @@ -20,12 +20,13 @@
4 void display_help();
5 void buildtag(char *buf, char *title, char *artist, char *album, char *year, char *comment, char *genre);
6 void set_filename(int argc,char *argv[]);
7 +void rtrim(char* astring);
9 int main(int argc, char *argv[])
11 FILE *fp;
12 - int verbose = 0, forced = 0, burn = 0, info = 0, all = 0;
13 - unsigned char sig[2];
14 + int verbose = 0, forced = 0, burn = 0, info = 0, all = 0, padtrack = 0;
15 + unsigned char sig[3];
16 char genre[1];
17 char input_char;
18 int i=0,plaatsen = 0;
19 @@ -36,13 +37,14 @@
21 if (argc < 2 ) /* If nothing is given */
23 - fprintf(stderr,"Mp3rename\n\nusage: [-vfhsbia] [file ...]\n\n");
24 + fprintf(stderr,"Mp3rename\n\nusage: [-vfhsbia] [file ...]\n\nUse 'mp3rename -h' for a usage summary\n\n");
26 return 0;
29 /* Lets checkout the options */
31 - while ((ch = getopt(argc, argv, "vfhsbia")) != -1)
32 + while ((ch = getopt(argc, argv, "vfhsbiap")) != -1)
33 switch (ch)
35 case 'v': /* Verbose mode */
36 @@ -66,8 +68,11 @@
37 case 'a': /* Ask everything */
38 all = 1;
39 break;
40 + case 'p':
41 + padtrack = 1;
42 + break;
43 default: /* If wrong option is given */
44 - fprintf(stderr,"Mp3rename\n\nusage: [-vfh] [file ...]\n\n");
45 + fprintf(stderr,"Mp3rename\n\nusage: [-vfhsbia] [file ...]\n\nUse 'mp3rename -h' for a usage summary\n\n");
46 exit(1);
48 argv += optind;
49 @@ -91,7 +96,7 @@
50 strcat(filenamelook,".mp3"); /* add .mp3 so that the filename will be complete */
52 do {
53 - char title[31]="", artist[31]="", album[31]="", year[5]="", comment[31]="", fbuf[4], newfilename[160]="",nieuw[150]="",dir[150]="",dirsource[200],fullline[228]="", burnname[29]="";
54 + char title[31]="", artist[31]="", album[31]="", year[5]="", comment[31]="", fbuf[4], newfilename[160]="",nieuw[150]="",dir[150]="",dirsource[200],fullline[228]="", burnname[29]="", track;
55 plaatsen = 0;
57 if ( !( fp=fopen(*argv,"rb+") ) ) /* If the file doesn exist */
58 @@ -104,6 +109,8 @@
59 /* Lets check if we have a real mp3 file */
61 fread(sig,sizeof(sig),1,fp);
62 + /* ID3v2 */
63 + if(sig[0]!='I' || sig[1]!='D' || sig[2]!='3'){
64 sig[0] &= 0xff;
65 sig[1] &= 0xf0;
66 if(!((sig[0] == 0xff) && (sig[1] == 0xf0)))
67 @@ -112,7 +119,8 @@
68 fclose(fp);
69 ++argv;
70 continue;
71 - }
72 + }
73 + }
75 /* Lets go to the beginning of the tag */
76 if ( fseek(fp, -128, SEEK_END ))
77 @@ -131,7 +139,14 @@
78 fread(artist,1,30,fp); artist[30] = '\0';
79 fread(album,1,30,fp); album[30] = '\0';
80 fread(year,1,4,fp); year[4] = '\0';
81 - fread(comment,1,30,fp); comment[30] = '\0';
82 + fread(comment,1,30,fp);
83 + if (comment[28] == '\0' && comment[29] != '\0') {
84 + /* ID3v1.1 - specify track number in the last byte of comment field*/
85 + track = comment[29];
86 + }
87 + else
88 + { track = 0; }
89 + comment[30] = '\0';
90 fread(genre,1,1,fp);
91 fseek(fp, -128, SEEK_END); /* back to the beginning of the tag */
93 @@ -290,6 +305,17 @@
95 printf("Artist : %s\n",artist);
96 printf("Title : %s\n",title);
97 + if(track!='\0')
98 + {
99 + if(track < 10 && padtrack == 1)
101 + printf("Track : 0%i\n",track);
103 + else
105 + printf("Track : %i\n",track);
108 printf("Album : %s\n",album);
109 printf("Year : %s\n\n",year);
110 ++argv;
111 @@ -297,31 +323,10 @@
114 /* Remove trailing spaces */
115 - i=strlen(artist)-1;
116 - while (i && artist[i]==' ')
118 - artist[i]='\0';
119 - i--;
122 - i=strlen(title)-1;
123 - while (i && title[i]==' ')
125 - title[i]='\0';
126 - i--;
128 - i=strlen(album)-1;
129 - while (i && album[i]==' ')
131 - album[i]='\0';
132 - i--;
134 - i=strlen(year)-1;
135 - while (i && year[i]==' ')
137 - year[i]='\0';
138 - i--;
140 + rtrim((char*)&artist);
141 + rtrim((char*)&title);
142 + rtrim((char*)&album);
143 + rtrim((char*)&year);
145 /* We go through the filenamelook until we find a &x combination
146 then we replace the &x with album/title/year/artis */
147 @@ -352,6 +357,18 @@
148 strcpy(newfilename,tmp);
149 i++;
150 break;
151 + case 'k':
152 + if(track < 10 && padtrack == 1)
154 + sprintf(tmp,"%s0%d",newfilename,track);
156 + else
158 + sprintf(tmp,"%s%d",newfilename,track);
160 + strcpy(newfilename,tmp);
161 + i++;
162 + break;
163 default:
164 printf("Illegal char in config file please use the option '-s help' for more information\n");
165 exit(1);
166 @@ -383,9 +400,11 @@
168 /* Build the new tag from the new names */
170 - buildtag(fullline,title,artist,album,year,comment,genre);
171 - fwrite(fullline,1,128,fp);
173 + if ((forced) || (all))
175 + buildtag(fullline,title,artist,album,year,comment,genre);
176 + fwrite(fullline,1,128,fp);
178 fclose(fp);
180 /* Lets catch illegal characters */
181 @@ -436,6 +455,17 @@
182 return 0;
185 +void rtrim(char* astring){
186 + int i;
188 + i=strlen(astring)-1;
189 + while (i && astring[i]==' ')
191 + astring[i]='\0';
192 + i--;
196 void buildtag(char *buf, char *title, char *artist, char *album, char *year, char *comment, char *genre)
199 @@ -448,7 +478,7 @@
200 strncat(buf,album,30);
201 pad(year,4);
202 strncat(buf,year,4);
203 - pad(comment,30);
204 + pad(comment,30);
205 strncat(buf,comment,30);
206 strncat(buf,genre,1);
208 @@ -476,6 +506,7 @@
209 printf("\t-h\t Display this help message.\n");
210 printf("\t-b\t Limit the file size to 32 chars.\n");
211 printf("\t-i\t Only show the id3tags.\n");
212 + printf("\t-p\t Pad the track number with a leading zero when less than 10.\n");
213 printf("\t-a\t Ask everything for the id3tag.\n\n");
214 printf("\t-s\t Set the default filename look.\n");
215 printf("\t \t for more help on this option: -s help\n\n");
216 @@ -500,7 +531,7 @@
217 printf("Mp3rename 0.6\n\n");
218 printf(" Use this option to set the default look of the file\n");
219 printf(" The information is saved in ~/.mp3rename\n");
220 - printf(" You can use &t title, &b album, &y year and &a artist\n\n");
221 + printf(" You can use &t title, &b album, &y year, &k track and &a artist\n\n");
222 printf(" Example : mp3rename -s '(&a)-&t-&b'\n");
223 printf(" for (artist)-title-album.mp3\n\n");
224 return;
225 --- mp3rename-0.6.orig/Makefile 2000-05-06 12:36:10.000000000 +0200
226 +++ mp3rename-0.6/Makefile 2007-05-17 04:29:18.000000000 +0200
227 @@ -2,6 +2,7 @@
228 SRCS = mp3rename.c
229 OBJS = mp3rename.o
230 RM = /bin/rm
231 +INSTALL = /bin/install
233 all: mp3rename
235 @@ -12,6 +13,5 @@
236 $(RM) -f $(OBJS) $(PROG) *~ *core
238 install:
239 - $(INSTALL) -c mp3rename $(PREFIX)/bin/mp3rename
240 - $(INSTALL) -c mp3rename.1.gz $(PREFIX)/man/man1/
242 \ Kein Zeilenumbruch am Dateiende.
243 + $(INSTALL) -D mp3rename.1.gz $(PREFIX)/usr/share/man/man1/mp3rename.1.gz
244 + $(INSTALL) -D mp3rename $(PREFIX)/usr/bin/mp3rename
245 --- mp3rename-0.6.orig/mp3rename.1 1970-01-01 01:00:00.000000000 +0100
246 +++ mp3rename-0.6/mp3rename.1 2007-05-17 04:46:24.000000000 +0200
247 @@ -0,0 +1,41 @@
248 +.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.35.
249 +.TH MP3RENAME "1" "September 2005" "Debian GNU/Linux" "User Commands"
250 +.SH NAME
251 +Mp3rename \- Rename mp3 files based on id3tags
252 +.SH DESCRIPTION
253 +Mp3rename 0.6
254 +.SH OPTIONS
255 +.TP
256 +\fB\-f\fR
257 +Force non id3 rename.
258 +.TP
259 +\fB\-v\fR
260 +Verbose mode.
261 +.TP
262 +\fB\-h\fR
263 +Display this help message.
264 +.TP
265 +\fB\-b\fR
266 +Limit the file size to 32 chars.
267 +.TP
268 +\fB\-i\fR
269 +Only show the id3tags.
270 +.TP
271 +\fB\-p\fR
272 +Pad the track number with a leading zero when less than 10.
273 +.TP
274 +\fB\-a\fR
275 +Ask everything for the id3tag.
276 +.TP
277 +\fB\-s\fR
278 +Set the default filename look.
279 +for more help on this option: \fB\-s\fR help
280 +.PP
281 +Sander Janssen <janssen@rendo.dekooi.nl>
282 +.IP
283 +Use this option to set the default look of the file
284 +The information is saved in ~/.mp3rename
285 +You can use &t title, &b album, &y year, &k track and &a artist
286 +.IP
287 +Example : mp3rename \fB\-s\fR '(&a)\-&t\-&b'
288 +for (artist)\-title\-album.mp3