Go Back   Android Forums > Android Discussion > Android Media
Android Media For Ringtones, Video, TV, Audio or anything else Multimedia related...

test: Reply
 
LinkBack Thread Tools
Old September 22nd, 2010, 04:34 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Sep 2010
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default Sync music via FTP from a Linux server

Good evening,

Part of why I bought a HTC Desire to replace my 2G iPhone was getting away from iTunes - piece of bloat required me to keep a Windows computer around, updating music was pesky, etc.

The plan with the HTC is to sync it over Wifi when it connects to my home network. The system it syncs with is a media server running Linux and storing my music collection.

I've gotten so far to have Tasker start FTPServer on connecting to Wifi, and have built a little script called every 10 minutes by cron that checks for presence of the phone. If it finds the phone, it connects and syncs a folder, then makes the ftp server on the phone shutdown, so it won't reconnect every 10 minutes.

So far, so good (I'll gladly share the bash script, if anybody wants to use. Needs some more polishing, though)

The bit that bugs me is playlists. I can create m3u playlists and copy them over fine, however once they are on the phone, they disappear from the Music folder and cannot be changed/deleted anymore - except by the built in music app. This is quite inconvenient, since I have a number of podcasts that get updated daily and that I'd like to take on the phone, with a playlist showing the newest episodes first. I can make the playlist easily on the computer, however the phone will end up with multiple copies of these playlists, which I can't get rid off.

Can anybody point me someplace that explains how Android handles playlists?

If there's no way, I'll work around by editing track/album MP3 tags and grouping my stuff together this way, but I'd prefer using simple playlists...

Advertisements
johnnychicago is offline  
Reply With Quote
sponsored links
Old September 23rd, 2010, 06:51 AM   #2 (permalink)
Member
 
Join Date: Aug 2010
Posts: 202
 
Device(s):
Carrier: Not Provided

Thanks: 8
Thanked 25 Times in 25 Posts
Default

You can longpress-delete playlists in the Music app.

I was unaware the playlists get moved, though this explains a side effect I'm seeing. My script wipes out a /sdcard/audio directory and reloads music and timestamp-named playlists, but the old .m3u files continue to display in the playlist screen. I have to delete them as described above. If they are getting moved this explains why the wipe doesn't clear them.

Does the auto-genned "recently added" faux playlist do anything for you?

Looking forward to other podcast-related posts.
__________________
Inspire 4G, CM7.2
TMo PAYG (no data). How I use it.
fratermus is offline  
Reply With Quote
Old September 23rd, 2010, 06:51 AM   #3 (permalink)
Member
 
Join Date: Aug 2010
Posts: 202
 
Device(s):
Carrier: Not Provided

Thanks: 8
Thanked 25 Times in 25 Posts
Default

[connection burp]
fratermus is offline  
Last edited by fratermus; September 23rd, 2010 at 06:54 AM.
Reply With Quote
Old September 23rd, 2010, 09:17 AM   #4 (permalink)
New Member
Thread Author (OP)
 
Join Date: Sep 2010
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by fratermus View Post
You can longpress-delete playlists in the Music app.
Yes, I found out about that, too. But it's quite inconvenient to always have manually get rid of them.

Quote:
I was unaware the playlists get moved, though this explains a side effect I'm seeing. My script wipes out a /sdcard/audio directory and reloads music and timestamp-named playlists, but the old .m3u files continue to display in the playlist screen. I have to delete them as described above. If they are getting moved this explains why the wipe doesn't clear them.
It does :-)

I don't wipe, but use lftp's reverse mirror to just copy what's changed.

If I can't find how to get rid of the playlists, I'll use them server side to relabel ID3 tags and that way tie my stuff together. Make the album tag the playlist name, or something along these lines.

Quote:
Does the auto-genned "recently added" faux playlist do anything for you?
I don't have that one.

Quote:
Looking forward to other podcast-related posts.
Ah, not much, really. Using podcatcher to download them, then creating a playlist of the last 50 of them with find, sort and head. My music lives in a directory structure suitable for Squeeze Server, I just want a comfortable way to sync a tiny subset of it to the phone.
johnnychicago is offline  
Reply With Quote
Old September 24th, 2010, 08:15 AM   #5 (permalink)
Member
 
Join Date: Aug 2010
Posts: 202
 
Device(s):
Carrier: Not Provided

Thanks: 8
Thanked 25 Times in 25 Posts
Default

Quote:
Originally Posted by johnnychicago View Post
Yes, I found out about that, too. But it's quite inconvenient to always have manually get rid of them.
I only sync after I've listened to all the 'casts so I'm deleting once a week or so. I can see how it would be a problem if syncing were more frequent.

Related: I suspect the .m3u is being converted to some kind of internal db on the device. I did a find on /sdcard for *.m3u and only found my original. Did the same on / in adb shell and found nothing.

Before I found the longpress deletion my workaround was to put a timestamp in the playlist name so I could tell them apart. :-o


Quote:
Originally Posted by johnnychicago View Post
I don't have that one.
Hmmm. Maybe it's a cyanomod thing. I thought his version of the Music app was stock; perhaps not. Claims to be v1.7.5.2 and the credits include Cyano, so I guess they hacked it.



Quote:
Originally Posted by johnnychicago View Post
Ah, not much, really. Using podcatcher to download them, then creating a playlist of the last 50 of them with find, sort and head. My music lives in a directory structure suitable for Squeeze Server, I just want a comfortable way to sync a tiny subset of it to the phone.
I meant in general. Music listeners seem to be the majority in media discussions. There probably are more of us who aren't talking much.

My setup looks like this:
  1. download - podracer does the downloads from a nightly cronjob, scripts do a bit of renaming and normalizing. I used to use hpodder but it disappeared from the ubuntu/debian repositories. I may have to find the source and roll my own. Weird-looking dependencies, though.
  2. script generates M3U and sync to G1

Do you listen to podcasts on the workstation mainly, and carry the subset on the phone for opportunistic listening? I wouldn't be able to keep track of what I had and hadn't listened to if I didn't do the total-wipe-and-load after listening to everything.
fratermus is offline  
Reply With Quote
Old September 24th, 2010, 08:21 AM   #6 (permalink)
Member
 
Join Date: Aug 2010
Posts: 202
 
Device(s):
Carrier: Not Provided

Thanks: 8
Thanked 25 Times in 25 Posts
Default

Update: check this post, then this.

At least we know how it works (and that it's been a problem for others).
fratermus is offline  
Reply With Quote
The Following User Says Thank You to fratermus For This Useful Post:
johnnychicago (September 27th, 2010)
Old September 27th, 2010, 08:52 AM   #7 (permalink)
New Member
Thread Author (OP)
 
Join Date: Sep 2010
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default

fratermus, thanks for those links.

I now have it running with basically using playlists to change ID3 tags on the computer, so I can group them on the phone (without actually transmitting the playlists to the phone), but I'll investigate in this.
johnnychicago is offline  
Reply With Quote
Old October 12th, 2010, 10:34 AM   #8 (permalink)
New Member
 
Join Date: Jun 2010
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Smile

Quote:
So far, so good (I'll gladly share the bash script, if anybody wants to use. Needs some more polishing, though)
Really!? Great, could you possibly share with me? Out of interest, what flavour of linux are you running on your mediaserver?
jwood79 is offline  
Reply With Quote
Old October 13th, 2010, 02:02 AM   #9 (permalink)
New Member
Thread Author (OP)
 
Join Date: Sep 2010
Posts: 4
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 1 Time in 1 Post
Default

Quote:
Originally Posted by jwood79 View Post
Really!? Great, could you possibly share with me? Out of interest, what flavour of linux are you running on your mediaserver?

Course, here you go:

I'm running FTPServer on the phone, being started at connection to my home wifi - trust you get along to set this up yourself. In order to facilitate life, I've told my wireless router to always hand out the same IP to the phone.

I have a music directory with mp3-files (and folders) that is being mirrored to the phone, as well as a sync directory in which I put M3U-Playlists (that I generate e.g. for my podcasts). Those playlists have the mp3-files with full pathnames, and the script copies those files to the music directory, and changes album information (on the copies) to reflect the playlist.

Script runs from cron every half hour and checks if the phone's there. If so, it compiles the playlist albums, mirrors the music folder to the phone, and switches off the FTPServer on the phone (to prevent it from resyncing every half hour).

Dependencies are netcat, id3v2 and lftp - probaby apt-gettable pretty much anywhere. My distribution is Debian.

Code:
#!/bin/bash

# settings

HOST="192.168.x.y"   #this is the phone's IP address
PORT="2222"
USER="abc"   #for FTPserver on phone
PASSWD="XXXXXXX"
SYNC_DIR="/mnt/sync/music"  # on the computer
PL_DIR="/mnt/sync"
PL_PREFIX="_Playlist-"
PHONE_DIR="/sdcard/Music"  # where the phone keeps its music
LOCKFILE="/var/lock/sync_android"

# first, scan the phone to see if it is there. If not, exit

nc -z "$HOST" "$PORT" || exit;


# lockfile

if [ ! -e $LOCKFILE ]; then
        trap "rm -f $LOCKFILE; exit" INT TERM EXIT
        touch $LOCKFILE
else
        exit
fi


# create folders for playlists

for PLFILE in "$PL_DIR"/*.m3u ; do
        PL_DIR_NAME="$SYNC_DIR/$PL_PREFIX$(basename "$PLFILE" .m3u)"
        mkdir "$PL_DIR_NAME" || rm "$PL_DIR_NAME"/*
        COUNTER="1"
        egrep -v "^#" "$PLFILE" |  while read LINE
        do
                cp "$LINE" "$PL_DIR_NAME"
                id3v2 -A "$PL_PREFIX-$(basename "$PLFILE" .m3u)" -T "$COUNTER" "$PL_DIR_NAME/$(basename "$LINE")"
                let "COUNTER+=1"
        done
done

# delete all m3u playlists now so they don't get to phone

rm -rf "$SYNC_DIR"/*.m3u
rm -f "$PL_DIR"/*.m3u

# since this may have taken a while, check again if phone is there

nc -z "$HOST" "$PORT" || exit;

# access phone by ftp, mirror the phone directory to the sync directory
# and shutdown the phone ftp server

lftp -p "$PORT" -u "$USER","$PASSWD" "$HOST" <<END_SCRIPT
mirror --reverse --delete-first --only-newer --verbose "$SYNC_DIR"  "$PHONE_DIR"
quote site shutdown
quit
END_SCRIPT

rm $LOCKFILE
exit 0
johnnychicago is offline  
Reply With Quote
The Following User Says Thank You to johnnychicago For This Useful Post:
jwood79 (October 13th, 2010)
Old October 13th, 2010, 02:30 PM   #10 (permalink)
New Member
 
Join Date: Jun 2010
Posts: 3
 
Device(s):
Carrier: Not Provided

Thanks: 1
Thanked 0 Times in 0 Posts
Default

Ah, brilliant, thanks a lot. I'm running an 'unslung' NSLU2 with a custom disto for my music. Hoping I can get a set up similar to yours working!
jwood79 is offline  
Reply With Quote
sponsored links
Reply
Tags
ftp, linux, music, playlist


Go Back   Android Forums > Android Discussion > Android Media
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 01:14 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.