github.com/boki/go-xmp@v1.0.1/models/itunes/movieinfo.go (about)

     1  // Copyright (c) 2017-2018 Alexander Eichhorn
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License"): you may
     4  // not use this file except in compliance with the License. You may obtain
     5  // a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
    11  // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
    12  // License for the specific language governing permissions and limitations
    13  // under the License.
    14  
    15  package itunes
    16  
    17  import (
    18  	"trimmer.io/go-xmp/xmp"
    19  	// "howett.net/plist"
    20  )
    21  
    22  type MovieInfo struct {
    23  	AssetInfo     *AssetInfo  `plist:"asset-info"    xmp:"iTunes:AssetInfo,attr"`
    24  	Studio        string      `plist:"studio"        xmp:"iTunes:Studio,attr"`
    25  	Cast          PersonArray `plist:"cast"          xmp:"iTunes:Cast"`
    26  	Directors     PersonArray `plist:"directors"     xmp:"iTunes:Directors"`
    27  	CoDirectors   PersonArray `plist:"codirectors"   xmp:"iTunes:CoDirectors"`
    28  	Screenwriters PersonArray `plist:"screenwriters" xmp:"iTunes:Screenwriters"`
    29  	Producers     PersonArray `plist:"producers"     xmp:"iTunes:Producers"`
    30  	CopyWarning   string      `plist:"copy-warning"  xmp:"iTunes:CopyWarning"`
    31  }
    32  
    33  // unmarshal Apple plist style XML file requires to import external
    34  // dependency howett.net/plist
    35  // func (x *MovieInfo) UnmarshalText(data []byte) error {
    36  // 	_, err := plist.Unmarshal(data, x)
    37  // 	return err
    38  // }
    39  
    40  type AssetInfo struct {
    41  	FileSize     int64  `plist:"file-size"     xmp:"iTunes:FileSize,attr"`
    42  	Flavor       string `plist:"flavor"        xmp:"iTunes:Flavor,attr"`
    43  	ScreenFormat string `plist:"screen-format" xmp:"iTunes:ScreenFormat,attr"`
    44  	Soundtrack   string `plist:"soundtrack"    xmp:"iTunes:Soundtrack,attr"`
    45  }
    46  
    47  type Person struct {
    48  	ID   string `plist:"adamId" xmp:"iTunes:AdamID,attr"`
    49  	Name string `plist:"name"   xmp:"iTunes:Name,attr"`
    50  }
    51  
    52  type PersonArray []Person
    53  
    54  func (a PersonArray) Typ() xmp.ArrayType {
    55  	return xmp.ArrayTypeUnordered
    56  }
    57  
    58  func (x PersonArray) MarshalXMP(e *xmp.Encoder, node *xmp.Node, m xmp.Model) error {
    59  	return xmp.MarshalArray(e, node, x.Typ(), x)
    60  }
    61  
    62  func (x *PersonArray) UnmarshalXMP(d *xmp.Decoder, node *xmp.Node, m xmp.Model) error {
    63  	return xmp.UnmarshalArray(d, node, x.Typ(), x)
    64  }