~rbn/rssfs

a8f17399381e5a7d348c1e574712ae04a02b4ced — Ruben Schuller 1 year, 10 months ago 1b7126e
prefer enclosures before GUID for media
1 files changed, 15 insertions(+), 14 deletions(-)

M rssfs.go
M rssfs.go => rssfs.go +15 -14
@@ 329,20 329,9 @@ func newItemDir(item *gofeed.Item, uid, gid string) (*itemDir, error) {
		newStaticFile("guid", q.Version, time.Now(), []byte(item.GUID), uid, gid),
	}

	// if the GUID is an URL, use that as media source, else use enclosures
	if mediaUrl(item.GUID) {
		if debug {
			log.Printf("adding GUID %v as mediaFile", item.GUID)
		}

		name := path.Base(item.GUID)

		media, err := newMediaFile(name, q.Version, time.Now(), item.GUID, uid, gid)
		if err != nil {
			return nil, err
		}
		children = append(children, media)
	} else {
	// if we have enclosures add them, if not check for GUID media.
	switch {
	case len(item.Enclosures) > 0:
		for _, v := range item.Enclosures {
			if mediaUrl(v.URL) {
				if debug {


@@ 358,6 347,18 @@ func newItemDir(item *gofeed.Item, uid, gid string) (*itemDir, error) {
				children = append(children, media)
			}
		}
	case mediaUrl(item.GUID):
		if debug {
			log.Printf("adding GUID %v as mediaFile", item.GUID)
		}

			name := path.Base(item.GUID)

			media, err := newMediaFile(name, q.Version, time.Now(), item.GUID, uid, gid)
			if err != nil {
				return nil, err
			}
			children = append(children, media)
	}

	i := &itemDir{