File: convert.cpp

package info (click to toggle)
id3v2 0.1.3-5
  • links: PTS
  • area: main
  • in suites: woody
  • size: 120 kB
  • ctags: 24
  • sloc: cpp: 1,153; makefile: 47
file content (83 lines) | stat: -rw-r--r-- 1,818 bytes parent folder | download
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
#include <iostream.h>
#include <id3/tag.h>
#include <stdlib.h>

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

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

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

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

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

      catch(ID3_Error err)
      {
        cout << endl;
        cout << err.GetErrorFile() << " (" << err.GetErrorLine() << "): "
             << err.GetErrorType() << ": " << err.GetErrorDesc() << endl;
        exit(1);
      }
    }

  return;
}


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

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

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

        luint nTags;

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

      catch(ID3_Error err)
      {
        cout << endl;
        cout << err.GetErrorFile() << " (" << err.GetErrorLine() << "): "
             << err.GetErrorType() << ": " << err.GetErrorDesc() << endl;
        exit(1);
      }
    }

  return;
}