-
Notifications
You must be signed in to change notification settings - Fork 0
/
gcs2xbmc.awk
114 lines (98 loc) · 2.41 KB
/
gcs2xbmc.awk
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
110
111
112
113
114
# $Id: gcs2xbmc.awk,v 1.4 2017/11/05 12:29:53 root Exp root $
# Transform GCstar DVD movie collection database into Kodi stub files
# kramski@web.de
# http://www.gcstar.org/
# http://kodi.wiki/view/Media_stubs
# Usage: gawk -f gcs2xbmc.awk mydatabase.gcs
# $Log: gcs2xbmc.awk,v $
# Revision 1.4 2017/11/05 12:29:53 root
# Change references from XBMC to Kodi
#
BEGIN {
FS="[=\"]"
# Since=-2 # set to -2 for all or set added date like this to skip old items:
Since=mktime("2017 11 04 00 00 00")
}
/<item/ { # Start of Item
Title="Unbekannt"
OutFile="unknown.disc"
Place="Unbekannt"
Format=""
Year=""
Added=0
next
}
/^ title=/ {
# Remove stopwords at end of title
sub(/ \([dD]er\)\"$/, "")
sub(/ \([dD]ie\)\"$/, "")
sub(/ \([dD]as\)\"$/, "")
sub(/ \([eE]ine\)\"$/, "")
sub(/ \([eE]in\)\"$/, "")
sub(/ \([tT]he\)\"$/, "")
sub(/ \([aA]n\)\"$/, "")
sub(/ \([aA]\)\"$/, "")
sub(/, [dD]er\"$/, "")
sub(/, [dD]ie\"$/, "")
sub(/, [dD]as\"$/, "")
sub(/, [eE]ine\"$/, "")
sub(/, [eE]in\"$/, "")
sub(/, [tT]he\"$/, "")
sub(/, [aA]n\"$/, "")
sub(/, [aA]\"$/, "")
Title=$3
# print "Title: >" Title "<"
next
}
/^ date=/ {
Year=$3
# print "Year: >" Year "<"
next
}
/^ place=/ {
Place=$3
next
}
/^ format=\"[dD][vV][dD]/ {
Format=".dvd"
next
}
/^ format=\"[bB][lL][uU]/ {
Format=".blu"
next
}
/^ added=/ {
Added=mktime(substr($3, 7, 4) " " substr($3, 4, 2) " " substr($3, 1, 2) " 00 00 00")
# print Added
next
}
/<\/item>/ {
if (Added > Since)
{
OutFile = Title
gsub(/ /, "_", OutFile)
gsub(/:/, "", OutFile)
gsub(/ä/, "a", OutFile)
gsub(/á/, "a", OutFile)
gsub(/à/, "a", OutFile)
gsub(/â/, "a", OutFile)
gsub(/é/, "e", OutFile)
gsub(/è/, "e", OutFile)
gsub(/ö/, "o", OutFile)
gsub(/ô/, "o", OutFile)
gsub(/ü/, "u", OutFile)
gsub(/Ä/, "A", OutFile)
gsub(/Ö/, "O", OutFile)
gsub(/Ü/, "U", OutFile)
gsub(/ß/, "ss", OutFile)
if (Year)
OutFile = OutFile "_(" Year ")"
OutFile = OutFile Format ".disc"
print "Writing " OutFile
print "<discstub>" > OutFile
print " <title>" Title "</title>" >> OutFile
print " <message>Standort: " Place "</message>" >> OutFile
print "</discstub>" >> OutFile
}
next
}