This repository has been archived by the owner on Oct 16, 2022. It is now read-only.
/
musync.conf
109 lines (86 loc) · 3.86 KB
/
musync.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
[import]
# the 'import' section is run prior to any existing lambda expression.
# therefore all that is imported here, will be available in any successive action.
# this is also a nice place to add your own library hacks!
os: os
sh: shutil
tmp: tempfile
m: musync.custom
#
# The musync.custom library has a set of useful methods:
#
# system(*args, **kw) -> boolean
# Run the command 'args' and return a boolean indicating weither zero was returned or not.
# 'kw' will be passed directly into Popen as keyword arguments.
#
# execute(*args, **kw) -> string
# Run the command 'args' and return the output to stdout
# will raise exception on non-zero status or empty output
#
# filter(data, *args, **kw) -> string
# Run the command 'args' and return the output to stdout
# 'data' will be written to stdin of the command
# will raise exception on non-zero status or empty output
[general]
### Static Variables ###
# root directory (used in 'targetpath').
root:"/warez/sd3/music"
# Which printer levels that should be suppressed on 'silent'
suppressed: ["notice", "warning"]
# Which configurations to overlay.
configurations: ["copy"]
### Behaviour Modifiers ###
pretend: False
force: False
silent: False
checkhash: True
debug: False
### Required Functions ###
## Therse are and must be lambda expression (e.g. of python type: types.FunctionType)
## Which could be a normal function (def) aswell imported elsewhere.
# How musync removes files
rm: lambda p: os.unlink(p.path)
# How musync add files (note; will be overwritten by 'configurations')
add: lambda src, dst: sh.move(src, dst)
# How musync performs checksums on a file, must return a file-unique string.
hash: lambda target: m.md5sum(target)
# targetpath helper functions
cfilter: lambda value: m.ue(m.lexer("/etc/musync.rules", value).lower())
cdir: lambda meta: "{0}/{1:0>4d}-{2}".format(cfilter(meta.artist) or "no-artist", meta.year or 0, cfilter(meta.album) or "no-album")
cfile: lambda meta: "{0:0>2d}-{1}.{2}".format(meta.track or 0, cfilter(meta.title) or "no-title", meta.ext)
targetpath: lambda p: os.path.join(cdir(p.meta), cfile(p.meta))
# Where to find the lock-database.
# this is just a flat-file database where each line indicates a file or directory that is locked.
# Musync will not perform any action against a locked file or directory other than 'unlock'
lockdb: lambda: os.path.join(root, ".lock")
[copy]
# Safe copy operation, this will be retried if the checksums do not match.
add: lambda src, dst: sh.copy(src, dst)
[move]
# Destructive move operation, if this fails, there will be no turning back.
add: lambda src, dst: sh.move(src, dst)
[dap]
### Static Variables ###
# New root for Digital Audio Players.
root:"/mnt/dap/music"
### Required Functions ###
# Transcoding (used if defined, e.g. not None)
# m.case: a helper function which matches the first argument either like:
# m.case("foo", foo=returnvalue)
# or:
# m.case("foo", ("foo", returnvalue));
# or:
# m.case("foo", (["foo", "bar", "baz"], returnvalue)); // a list or a tuple where any matches.
#
# therefore, the extension will be matched against different selections.
transcode:lambda src: m.case(src.ext, (('flac', 'wav'), x_to_ogg_t), mp3=mp3_to_ogg_t)
# Transcoding helper functions.
x_to_ogg_t = ('ogg', lambda src, dst: ogg_encode(src, dst))
# transcoding from ogg to mp3 requires a temporary file, use in_tmp to pass one as the forst argument to mpt_to_ogg.
# in_tmp will make sure that the temporary file is removed no matter what.
mp3_to_ogg_t = ('ogg', lambda src, dst: m.in_tmp(mp3_to_ogg, src, dst))
# EVEN MORE helpers.
mp3_decode: lambda src, dst: m.system("mpg321", src, "-w", dst)
ogg_encode: lambda src, dst: m.system("/usr/bin/oggenc", src, "-o", dst, "-q", "8")
# First do the mp3_decode, followed by an ogg_encode
mp3_to_ogg: lambda tmp, src, dst: m.each(lambda: mp3_decode(src, tmp), lambda: ogg_encode(tmp, dst))