mirror of https://github.com/perkeep/perkeep.git
third_party/taglib: Update to ef5ded85df.
Change-Id: I536e08d2c0184b1d2abe52f3f139be35e9f331dd
This commit is contained in:
parent
d341375188
commit
2c03760157
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
import (
|
||||
|
@ -55,12 +69,12 @@ func (t *Id3v23Tag) Genre() string {
|
|||
}
|
||||
|
||||
func (t *Id3v23Tag) Year() time.Time {
|
||||
yearStr := getSimpleId3v23TextFrame(t.Frames["TDRC"])
|
||||
if len(yearStr) < 4 {
|
||||
yearStr := getSimpleId3v23TextFrame(t.Frames["TYER"])
|
||||
if len(yearStr) != 4 {
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
yearInt, err := strconv.Atoi(yearStr[0:4])
|
||||
yearInt, err := strconv.Atoi(yearStr)
|
||||
if err != nil {
|
||||
return time.Time{}
|
||||
}
|
||||
|
@ -76,6 +90,31 @@ func (t *Id3v23Tag) Track() uint32 {
|
|||
return uint32(track)
|
||||
}
|
||||
|
||||
func (t *Id3v23Tag) Disc() uint32 {
|
||||
disc, err := parseLeadingInt(getSimpleId3v23TextFrame(t.Frames["TPOS"]))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return uint32(disc)
|
||||
}
|
||||
|
||||
func (t *Id3v23Tag) CustomFrames() map[string]string {
|
||||
info := make(map[string]string)
|
||||
for _, frame := range t.Frames["TXXX"] {
|
||||
// See http://id3.org/id3v2.3.0#User_defined_text_information_frame.
|
||||
// TXXX frames contain NUL-separated descriptions and values.
|
||||
parts, err := GetId3v23TextIdentificationFrame(frame)
|
||||
if err == nil && len(parts) == 2 {
|
||||
info[parts[0]] = parts[1]
|
||||
}
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (t *Id3v23Tag) TagSize() uint32 {
|
||||
return 10 + t.Header.Size
|
||||
}
|
||||
|
||||
type Id3v23Header struct {
|
||||
MinorVersion byte
|
||||
Flags Id3v23HeaderFlags
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
func GetId3v23TextIdentificationFrame(frame *Id3v23Frame) ([]string, error) {
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
import (
|
||||
|
@ -76,6 +90,32 @@ func (t *Id3v24Tag) Track() uint32 {
|
|||
return uint32(track)
|
||||
}
|
||||
|
||||
func (t *Id3v24Tag) Disc() uint32 {
|
||||
disc, err := parseLeadingInt(getSimpleId3v24TextFrame(t.Frames["TPOS"]))
|
||||
if err != nil {
|
||||
return 0
|
||||
}
|
||||
return uint32(disc)
|
||||
}
|
||||
|
||||
func (t *Id3v24Tag) CustomFrames() map[string]string {
|
||||
info := make(map[string]string)
|
||||
for _, frame := range t.Frames["TXXX"] {
|
||||
// See "4.2.6. User defined text information frame" at
|
||||
// http://id3.org/id3v2.4.0-frames. TXXX frames contain
|
||||
// NUL-separated descriptions and values.
|
||||
parts, err := GetId3v24TextIdentificationFrame(frame)
|
||||
if err == nil && len(parts) == 2 {
|
||||
info[parts[0]] = parts[1]
|
||||
}
|
||||
}
|
||||
return info
|
||||
}
|
||||
|
||||
func (t *Id3v24Tag) TagSize() uint32 {
|
||||
return 10 + t.Header.Size
|
||||
}
|
||||
|
||||
type Id3v24Header struct {
|
||||
MinorVersion byte
|
||||
Flags Id3v24HeaderFlags
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
// import (
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
func GetId3v24TextIdentificationFrame(frame *Id3v24Frame) ([]string, error) {
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package id3
|
||||
|
||||
import (
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package taglib provides utilities for parsing audio tags in
|
||||
// various formats.
|
||||
package taglib
|
||||
|
@ -26,6 +40,16 @@ type GenericTag interface {
|
|||
Genre() string
|
||||
Year() time.Time
|
||||
Track() uint32
|
||||
Disc() uint32
|
||||
|
||||
// CustomFrames returns non-standard, user-defined frames as a map from
|
||||
// descriptions (e.g. "PERFORMER", "MusicBrainz Album Id", etc.) to
|
||||
// values.
|
||||
CustomFrames() map[string]string
|
||||
|
||||
// TagSize returns the total size of the tag's header and frames,
|
||||
// i.e. the position at which audio data starts.
|
||||
TagSize() uint32
|
||||
}
|
||||
|
||||
// Decode reads r and determines which tag format the data is in, if
|
||||
|
|
|
@ -1,3 +1,17 @@
|
|||
// Copyright 2013 Google Inc. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package taglib
|
||||
|
||||
import (
|
||||
|
@ -11,8 +25,11 @@ func ExampleDecode() {
|
|||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
tag, err := Decode(f)
|
||||
fi, err := f.Stat()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
tag, err := Decode(f, fi.Size())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -22,7 +39,9 @@ func ExampleDecode() {
|
|||
fmt.Println("Album:", tag.Album())
|
||||
fmt.Println("Genre:", tag.Genre())
|
||||
fmt.Println("Year:", tag.Year())
|
||||
fmt.Println("Disc:", tag.Disc())
|
||||
fmt.Println("Track:", tag.Track())
|
||||
fmt.Println("Performer:", tag.CustomFrames()["PERFORMER"])
|
||||
|
||||
// Output:
|
||||
// Title: Test Name
|
||||
|
@ -30,5 +49,7 @@ func ExampleDecode() {
|
|||
// Album: Test Album
|
||||
// Genre: Classical
|
||||
// Year: 2008-01-01 00:00:00 +0000 UTC
|
||||
// Disc: 3
|
||||
// Track: 7
|
||||
// Performer: Somebody
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue