eizi123
Anmeldungsdatum: 7. April 2013
Beiträge: 90
|
Hallo, da ich Banshee einfach nicht dazu bewegen kann mein Xperia Z2 zu syncen ohne abzuschmieren erledige ich nun diese Aufgabe einfach über rsync. Ein großes Problem ist aber das Banshee komischerweise die Playslists unter .config/banshee-1/banshee.db in einer Datenbank speichert. Da ich keine Ahnung von Programmieren/Datenbanken habe stellt dies eine große Hürde für mich dar.
Das Ziel wäre per Script die einzelnen Playlists automatisiert als .m3u zu exportiert. Ich weiß das dies über Banshee grafisch geht, dies sollte aber in einem Script gemeinsam mit rsync automatischt ausgeführt werden da bei einer Änderung der Playlist am PC dies am Smartphone ebenfalls geändert werden sollte. Wie stelle ich das am besten an? Ist es viel Programmierarbeit?
Würde eventuell ein findiger Programmierer hier dies übernehmen? Vorausgesetzt es ist nicht zu viel arbeit...wie gesagt ich habe keine Ahnung. mfg Max
|
Lysander
Anmeldungsdatum: 30. Juli 2008
Beiträge: 2669
Wohnort: Hamburg
|
Das klingt nach einer SQLite Datenbank. Diese kannst Du einfach über das Fiefox-Plugin sqlitemanager oder ein lokaes GUI-Frontend a la sqliteman versuchen zu öffnen. Mit ein wenig Glück gibt es eine "Playlists"-Tabelle, in der die Daten der Playlist abgelegt sind. Von allen Daten brauchst Du für eine M3U ja lediglich den (absoluten) Namen zur Datei. Ich denke diese Infos sollten sich leicht in eine Textdatei exportieren lassen ☺
|
eizi123
(Themenstarter)
Anmeldungsdatum: 7. April 2013
Beiträge: 90
|
Hallo, danke für deine Antwort. Habe nun mit sqliteman die DB durchsucht, doch mir ist nicht klar woher die Playlist die TrackID nimmt um die einelnen Titel zu verknüpfen..es gibt keine gmeinsamen Columns. Ich habe die Datenbank mal angehängt, wäre toll wenn du mir helfen könntest.
- banshee.db.tar.gz (416.4 KiB)
- Download banshee.db.tar.gz
|
Lysander
Anmeldungsdatum: 30. Juli 2008
Beiträge: 2669
Wohnort: Hamburg
|
Die Tabellen coretracks und coreplaylists definieren die einzelnen Songs und die einzelnen Playlisten. Die n:m-Relation wird über die Tabelle coreplaylistentries realisiert. Ich habe mit dia mal ein kleines Bild von den Schlüsselverknüpfungen erstellt: Ungültiges MakroDieses Makro ist nicht verfügbar Mittels einer einfachen Query mit JOINs erhält man alle URIs von Songs in einer bestimmten Playliste:
| select Uri
from coretracks ct
inner join coreplaylistentries cpe on ct.TrackID = cpe.TrackID
inner join coreplaylists cp on cpe.PlaylistID = cp.PlaylistID
where cp.Name = 'N'
|
Im sqliteman kann man sich dann die Ergebnisse einer Query bequem in verschiedene Formate exportieren lassen ☺
- Bilder
|
eizi123
(Themenstarter)
Anmeldungsdatum: 7. April 2013
Beiträge: 90
|
Danke-ich habe die Abfrage in sqliteman erflogreich ausführen können, jedoch habe ich nun ein fertiges Perl-Script im Netz gefunden welches die Playlists exportiert. Ich kann mir mittels perl banshee-playlist.pl --list Die angelegten Playlisten in der DB anzeigen lassen. Wenn ich jedoch die Playlist gee exportieren möchte erstellt das Script eine leere M3U-Datei Namens gee. banshee-playlist.pl --export gee Wie funktioniert das? Hier die Source: 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237 | #! /usr/bin/env perl
# create m3u file for banshee playlist
use warnings;
use strict;
use DBI;
use File::Basename;
use Getopt::Long;
use IO::File;
use Pod::Usage;
use URI::Escape;
my $pkg = 'banshee-playlist';
my $version = '0.2';
my $db = "$ENV{HOME}/.config/banshee-1/banshee.db";
my ($export, $list, $quiet);
unless (GetOptions(help => sub { &pod2usage(-exitval => 0) },
'db=s' => \$db,
export => \$export,
list => \$list,
quiet => \$quiet,
version => sub { print "$pkg $version\n"; exit(0) }
))
{
warn("Try `$pkg --help' for more information.\n");
exit(1);
}
# connect to database
die("$pkg: banshee database does not exist or is not readable")
unless (-f $db && -r $db);
my $dbh = DBI->connect("dbi:SQLite:dbname=$db", '', '',
{ RaiseError => 1, AutoCommit => 0 });
# see what user wants
if ($list) {
&list_playlists($dbh);
}
else {
# get playlist
die("$pkg: incorrect number of arguments: @ARGV") unless @ARGV == 1;
my ($playlist) = @ARGV;
&get_list($dbh, $playlist, $export);
}
$dbh->disconnect;
exit(0);
# list the playlists
sub list_playlists {
my ($dbh) = @_;
my $list_q = q(select PlaylistID, Name from CorePlaylists);
my $list_s = $dbh->prepare($list_q);
$list_s->execute();
while (my $row = $list_s->fetchrow_arrayref) {
my ($id, $name) = @$row;
print("$name\n");
}
return;
}
sub get_list {
my ($dbh, $playlist, $export) = @_;
# prep query
my $track_q = q(
select t.Uri, e.ViewOrder, a.Name, t.Title, t.TrackNumber,
l.Title, t.Year, t.Genre, t.Duration/1000
from CorePlaylists as p
join CorePlaylistEntries as e on e.PlaylistID = p.PlaylistID
join CoreTracks as t on t.TrackID = e.TrackID
join CoreArtists as a on a.ArtistID = t.ArtistID
join CoreAlbums as l on l.AlbumID = t.AlbumID
where p.Name = ?
order by e.ViewOrder, e.EntryID
);
my $track_s = $dbh->prepare($track_q);
# execute query
$track_s->execute($playlist);
# open m3u file
my $m3u = IO::File->new(">$playlist.m3u");
die "$pkg: failed to open m3u file: $!" unless defined($m3u);
$m3u->print("#EXTM3U\n");
# get tracks and start loop
while (my $row = $track_s->fetchrow_arrayref) {
my (%track);
@track{qw(uri order artist title n album year genre duration)} = @$row;
my $path = $track{uri};
$path =~ s,^file://,,;
$path = uri_unescape($path);
if (! -f $path) {
warn("$pkg: file does not exist: '$path'\n");
}
if ($export) {
my $rv = &export_file($path, %track);
if (!$rv) {
warn("$pkg: failed to export file: $path");
}
else {
$path = $rv;
}
}
$m3u->print("#EXTINF:$track{duration},$track{artist} - $track{title}\n");
$m3u->print("$path\n");
}
$m3u->close;
}
# export music files
sub export_file {
my ($path, %track) = @_;
# parse file path
my @exts = qw(.mp3 .ogg .flac .m4a);
my ($base, $dir, $suffix) = fileparse($path, @exts);
if (!$suffix) {
warn("$pkg: unknown suffix: $path");
return;
}
my $wav = "$base.wav";
my $mp3 = "$base.mp3";
print("$pkg: export $path to $mp3\n") unless $quiet;
# see if our work is already done
if (-f $mp3) {
warn("$pkg: file already exists: $mp3");
return $mp3;
}
# create wav
my @wav_cmd = (qw(mplayer -really-quiet -nolirc -vo null -vc dummy -ao),
"pcm:waveheader:file=$wav", $path);
if (system(@wav_cmd) != 0) {
warn("$pkg: failed to convert audio file to wav: $path");
return;
}
# create mp3
my @lame_cmd = (qw(lame --quiet --preset medium), '--ta', $track{artist},
'--tl', $track{album}, '--ty', $track{year},
'--tn', $track{n}, '--tg', $track{genre},
'--tt', $track{title}, $wav, $mp3);
if (system(@lame_cmd) != 0) {
warn("$pkg: failed to convert wav to mp3: $path");
unlink($wav);
return;
}
unlink($wav);
return $mp3;
}
__END__
=pod
=head1 NAME
banshee-playlist - list contents of banshee playlists
=head1 SYNOPSIS
B<banshee-playlist> [OPTIONS]... [PLAYLIST]
=head1 DESCRIPTION
This programs reads a Banshee database and outputs playlist
information. It can create an m3u file for a PLAYLIST (the default),
list the available playlists, and optionally export the song music
files from a playlist.
=head1 OPTIONS
If an argument to a long option is mandatory, it is also mandatory for
the corresponding short option; the same is true for optional arguments.
=over 4
=item --db=PATH
Use PATH for banshee database rather than the default,
C<~/.config/banshee-1/banshee.db>.
=item --export
Write the m3u file and export the music files as LAME-encoded medium
quality MP3 files in the current directory.
=item --help
Display a brief description and listing of all available options.
=item --list
List the banshee playlists.
=item --version
Output version information and exit.
=item --
Terminate option processing. This option is useful when file names
begin with a dash (-).
=back
=head1 EXAMPLES
To get a list of the playlists in banshee, run
$ banshee-playlist --list
To write an m3u file for playlist Workout and export the song files to
the current directory, run
$ banshee-playlist --export Workout
=head1 BUGS
Please email the author if you identify a bug.
=head1 SEE ALSO
sqlite3(1), banshee(1)
=head1 AUTHOR
David Dooling <banjo@users.sourceforge.net>
=cut
|
|