Welcome to mirror list, hosted at ThFree Co, Russian Federation.

File_PropertyList.cpp « Tag « MediaInfo « MediaInfo « thirdparty « src - github.com/mpc-hc/mpc-hc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7a983f3c87d72321f895ef20b50951d607329f37 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*  Copyright (c) MediaArea.net SARL. All Rights Reserved.
 *
 *  Use of this source code is governed by a BSD-style license that can
 *  be found in the License.html file in the root of the source tree.
 */

//---------------------------------------------------------------------------
// Pre-compilation
#include "MediaInfo/PreComp.h"
#ifdef __BORLANDC__
    #pragma hdrstop
#endif
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#include "MediaInfo/Setup.h"
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#if defined(MEDIAINFO_PROPERTYLIST_YES)
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
#include "MediaInfo/Tag/File_PropertyList.h"
#include <cstring>
#include "tinyxml2.h"
using namespace tinyxml2;
using namespace std;
//---------------------------------------------------------------------------

namespace MediaInfoLib
{

//***************************************************************************
// Buffer - File header
//***************************************************************************

//---------------------------------------------------------------------------
const char* PropertyList_key(const string &key)
{
    if (key=="director" || key=="directors")
        return "Director";
    if (key=="codirector" || key=="codirectors")
        return "CoDirector";
    if (key=="producer" || key=="producers")
        return "Producer";
    if (key=="coproducer" || key=="coproducers")
        return "CoProducer";
    if (key=="screenwriter" || key=="screenwriters")
        return "ScreenplayBy";
    if (key=="studio" || key=="studios")
        return "ProductionStudio";
    if (key=="cast")
        return "Actor";
    return key.c_str();
}

//***************************************************************************
// Buffer - File header
//***************************************************************************

//---------------------------------------------------------------------------
bool File_PropertyList::FileHeader_Begin()
{
    XMLDocument document;
    if (!FileHeader_Begin_XML(document))
       return false;

    XMLElement* plist=document.FirstChildElement("plist");
    if (!plist)
    {
        Reject("XMP");
        return false;
    }

    XMLElement* dict=plist->FirstChildElement("dict");
    if (!dict)
    {
        Reject("XMP");
        return false;
    }

    Accept("PropertyList");

    string key;
    for (XMLElement* dict_Item=dict->FirstChildElement(); dict_Item; dict_Item=dict_Item->NextSiblingElement())
    {
        //key
        if (!strcmp(dict_Item->Value(), "key"))
        {
            const char* Text=dict_Item->GetText();
            if (Text)
                key=Text;
        }

        //string
        if (!strcmp(dict_Item->Value(), "string"))
        {
            const char* Text=dict_Item->GetText();
            if (Text)
                Fill(Stream_General, 0, PropertyList_key(key), Text);

            key.clear();
        }

        //string
        if (!strcmp(dict_Item->Value(), "array"))
        {
            for (XMLElement* array_Item=dict_Item->FirstChildElement(); array_Item; array_Item=array_Item->NextSiblingElement())
            {
                //dict
                if (!strcmp(array_Item->Value(), "dict"))
                {
                    string key2;
                    for (XMLElement* dict2_Item=array_Item->FirstChildElement(); dict2_Item; dict2_Item=dict2_Item->NextSiblingElement())
                    {
                        //key
                        if (!strcmp(dict2_Item->Value(), "key"))
                        {
                            const char* Text=dict2_Item->GetText();
                            if (Text)
                                key2=Text;
                        }

                        //string
                        if (!strcmp(dict2_Item->Value(), "string"))
                        {
                            const char* Text2=dict2_Item->GetText();
                            if (Text2)
                                Fill(Stream_General, 0, key2=="name"?PropertyList_key(key):((string(PropertyList_key(key))+", "+key2).c_str()), Text2);

                            key2.clear();
                        }
                    }
                }
            }

            key.clear();
        }
    }

    Finish();
    return true;
}

} //NameSpace

#endif //MEDIAINFO_PROPERTYLIST_YES