Switch to unified view

a/src/mediaserver/cdplugins/uprcl/uprclutils.py b/src/mediaserver/cdplugins/uprcl/uprclutils.py
...
...
14
    'audio/x-aiff',
14
    'audio/x-aiff',
15
    'audio/x-wav',
15
    'audio/x-wav',
16
    'inode/directory'
16
    'inode/directory'
17
    ])
17
    ])
18
18
19
upnp2rclfields = {'upnp:album': 'album',
19
# Correspondance between Recoll field names (on the right), defined by
20
                  'releasedate' : 'date',
20
# rclaudio and the Recoll configuration 'fields' file, and what
21
# plgwithslave.cxx expects, which is less than consistent.
22
upnp2rclfields = {
23
    'dc:creator' : '?',
24
    'upnp:genre' : 'genre',
25
    'upnp:album': 'album',
21
                  'upnp:originalTrackNumber' : 'tracknumber',
26
    'upnp:originalTrackNumber' : 'tracknumber',
22
                  'upnp:artist' : 'artist',
23
                  'upnp:genre' : 'genre',
24
                  'res:mime' : 'mtype',
27
    'res:mime' : 'mtype',
25
                  'duration' : 'duration',
26
                  'res:samplefreq' : 'sample_rate'
28
    'res:samplefreq' : 'sample_rate',
27
                  }
29
    'res:channels' : 'channels',
30
    'res:bitrate' : 'bitrate',
31
    'duration' : 'duration',
32
    'upnp:artist' : 'artist',
33
    'dc:date' : 'date',
34
    'tt' : 'title',
35
    'composer' : 'composer',
36
    'conductor' : 'conductor'
37
    }
28
    
38
    
29
def rcldoctoentry(id, pid, httphp, pathprefix, doc):
39
def rcldoctoentry(id, pid, httphp, pathprefix, doc):
30
    """
40
    """
31
    Transform a Doc objects into the format expected by the parent
41
    Transform a Doc objects into the format expected by the parent
32
42
...
...
57
    if doc.mtype not in audiomtypes:
67
    if doc.mtype not in audiomtypes:
58
        return li
68
        return li
59
69
60
    li['pid'] = pid
70
    li['pid'] = pid
61
    li['id'] = id
71
    li['id'] = id
62
    li['tp'] = 'ct' if doc.mtype == 'inode/directory' else 'it'
72
    if doc.mtype == 'inode/directory':
63
    # Why no dc.title??
73
        li['tp'] = 'ct'
64
    li['tt'] = doc.title
74
        li['upnp:class'] = 'object.container'
65
75
    else:
76
        li['tp']= 'it'
66
    # TBD
77
        # TBD
67
    li['upnp:class'] = 'object.item.audioItem.musicTrack'
78
        li['upnp:class'] = 'object.item.audioItem.musicTrack'
79
80
    for oname,dname in upnp2rclfields.iteritems():
81
        val = getattr(doc, dname)
82
        if val:
83
            li[oname] = val
68
84
69
    # TBD Date format ?
85
    # TBD Date format ?
70
    # !! Albumart will have to come from somewhere else !
86
    # !! Albumart will have to come from somewhere else !
71
    # li['upnp:class'] = doc.upnpclass
72
    #li['res:channels'] =
73
    #li['res:size'] =
74
    #li['res:bitrate'] = 
75
    ###     #if doc.albumarturi:
87
    ###     #if doc.albumarturi:
76
    ###        #li['upnp:albumArtURI'] = track.album.image
88
    ###        #li['upnp:albumArtURI'] = track.album.image
77
    ### li['discnumber'] = str(track.disc_num)
89
    ### li['discnumber'] = str(track.disc_num)
78
    #albumartist=
90
    #albumartist=
79
    #comment=
91
    #comment=
...
...
82
    #discnumber=
94
    #discnumber=
83
    #genre=
95
    #genre=
84
    #lyricist=
96
    #lyricist=
85
    #lyrics=
97
    #lyrics=
86
98
87
    for oname,dname in upnp2rclfields.iteritems():
88
        val = getattr(doc, dname)
89
        if val:
90
            li[oname] = val
91
99
92
    try:
100
    try:
93
        val = li['upnp:originalTrackNumber']
101
        val = li['upnp:originalTrackNumber']
94
        l = val.split('/')
102
        l = val.split('/')
95
        li['upnp:originalTrackNumber'] = l[0]
103
        li['upnp:originalTrackNumber'] = l[0]
...
...
104
    path = pathprefix + path
112
    path = pathprefix + path
105
    li['uri'] = "http://%s%s" % (httphp, urllib.quote(path))
113
    li['uri'] = "http://%s%s" % (httphp, urllib.quote(path))
106
    uplog("rcldoctoentry: uri: %s" % li['uri'])
114
    uplog("rcldoctoentry: uri: %s" % li['uri'])
107
    return li
115
    return li
108
116
117
def docfolder(doc):
118
    path = doc.getbinurl()
119
    path = path[7:]
120
    return os.path.dirname(path)
121
109
def cmpentries(e1, e2):
122
def cmpentries(e1, e2):
110
    tp1 = e1['tp']
123
    tp1 = e1['tp']
111
    tp2 = e2['tp']
124
    tp2 = e2['tp']
112
    isct1 = tp1 == 'ct'
125
    isct1 = tp1 == 'ct'
113
    isct2 = tp2 == 'ct'
126
    isct2 = tp2 == 'ct'