File: convert.cpp

package info (click to toggle)
id3v2 0.1.11-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 296 kB
  • ctags: 76
  • sloc: cpp: 2,212; makefile: 123
file content (74 lines) | stat: -rw-r--r-- 1,587 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
#include <cstdio>
#include <iostream>
#include <id3/tag.h>
#include <cstdlib>

void DeleteTag(int argc, char *argv[], int optind, int whichTags)
{

    FILE * fp;
    
    for (size_t nIndex = optind; nIndex < argc; nIndex++)
    {
      /* cludgy to check if we have the proper perms */
      fp = fopen(argv[nIndex], "r+");
      if (fp == NULL) { /* file didn't open */
        fprintf(stderr, "fopen: %s: ", argv[nIndex]);
        perror("id3v2");
        continue;
      }
      fclose(fp);

      ID3_Tag myTag;

      std::cout << "Stripping id3 tag in \"";
      std::cout << argv[nIndex] << "\"...";

      myTag.Clear();
      myTag.Link(argv[nIndex], ID3TT_ALL);

      luint nTags;
      switch(whichTags) 
      {
        case 1: 
          nTags = myTag.Strip(ID3TT_ID3V1);
          std::cout << "id3v1 ";
          break;
        case 2:
          nTags = myTag.Strip(ID3TT_ID3V2);
          std::cout << "id3v2 ";
          break; 
        case 0:
        default:
          nTags = myTag.Strip(ID3TT_ID3);
          std::cout << "id3v1 and v2 ";
      }

      std::cout << "stripped." << std::endl;
    }

  return;
}


void ConvertTag(int argc, char *argv[], int optind)
{
    for (size_t nIndex = optind; nIndex < argc; nIndex++)
    {
      ID3_Tag myTag;

      std::cout << "Converting id3v1 tag to id3v2 in ";
      std::cout << argv[nIndex] << "...";

      myTag.Clear();
      myTag.Link(argv[nIndex], ID3TT_ALL);

      luint nTags;

      nTags = myTag.Update(ID3TT_ID3V2);
      std::cout << " converted ";
      std::cout << std::endl;
    }

  return;
}