<commit_before>package dms

import (
	"encoding/xml"
	"errors"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
	"path"
	"path/filepath"
	"sort"
	"strings"
	"time"

	"bitbucket.org/anacrolix/dms/misc"

	"bitbucket.org/anacrolix/dms/dlna"
	"bitbucket.org/anacrolix/dms/ffmpeg"
	"bitbucket.org/anacrolix/dms/upnp"
	"bitbucket.org/anacrolix/dms/upnpav"
)

type contentDirectoryService struct {
	*Server
}

// Turns the given entry and DMS host into a UPnP object. A nil object is
// returned if the entry is not of interest.
func (me *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fileInfo os.FileInfo, host, userAgent string) interface{} {
	obj := upnpav.Object{
		ID:         cdsObject.ID(),
		Restricted: 1,
		ParentID:   cdsObject.ParentID(),
	}
	if fileInfo.IsDir() {
		if !me.objectHasChildren(cdsObject) {
			return nil
		}
		obj.Class = "object.container.storageFolder"
		obj.Title = fileInfo.Name()
		return upnpav.Container{
			Object:     obj,
			ChildCount: me.objectChildCount(cdsObject),
		}
	}
	if !fileInfo.Mode().IsRegular() {
		return nil
	}
	entryFilePath := cdsObject.FilePath()
	mimeType := mimeTypeByPath(entryFilePath)
	mimeTypeType := mimeType.Type()
	if !mimeTypeType.IsMedia() {
		return nil
	}
	iconURI := (&url.URL{
		Scheme: "http",
		Host:   host,<commit_msg>Emergency fix: Don't do container child count/empty filter for now as it recursively scans entire path<commit_after>package dms

import (
	"encoding/xml"
	"errors"
	"fmt"
	"log"
	"net/http"
	"net/url"
	"os"
	"path"
	"path/filepath"
	"sort"
	"strings"
	"time"

	"bitbucket.org/anacrolix/dms/misc"

	"bitbucket.org/anacrolix/dms/dlna"
	"bitbucket.org/anacrolix/dms/ffmpeg"
	"bitbucket.org/anacrolix/dms/upnp"
	"bitbucket.org/anacrolix/dms/upnpav"
)

type contentDirectoryService struct {
	*Server
}

// Turns the given entry and DMS host into a UPnP object. A nil object is
// returned if the entry is not of interest.
func (me *contentDirectoryService) cdsObjectToUpnpavObject(cdsObject object, fileInfo os.FileInfo, host, userAgent string) interface{} {
	obj := upnpav.Object{
		ID:         cdsObject.ID(),
		Restricted: 1,
		ParentID:   cdsObject.ParentID(),
	}
	if fileInfo.IsDir() {
		//if !me.objectHasChildren(cdsObject) {
	//		return nil
	//	}
		obj.Class = "object.container.storageFolder"
		obj.Title = fileInfo.Name()
		return upnpav.Container{
			Object:     obj,
	//		ChildCount: me.objectChildCount(cdsObject),
		}
	}
	if !fileInfo.Mode().IsRegular() {
		return nil
	}
	entryFilePath := cdsObject.FilePath()
	mimeType := mimeTypeByPath(entryFilePath)
	mimeTypeType := mimeType.Type()
	if !mimeTypeType.IsMedia() {
		return nil
	}
	iconURI := (&url.URL{
		Scheme: "http",
		Host:   host,
{'fraction_non_alphanumeric': 0.1330122267506484, 'fraction_numerical': 0.0007410151908114116, 'mean_word_length': 3.9541284403669725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5346435', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1044, 'n_words': 218}