BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 12-02-2010, 01:54 AM   #1
excetara2
New Member
 
Join Date: Dec 2010
Model: 9650
PIN: N/A
Carrier: Vodafone (Verizon Branded)
Posts: 2
Default Script to Copy/Sync Playlists and Music to Blackberry

Please Login to Remove!

This is a script I wrote to copy my playlists and associated Music from rhythmbox over to a blackberry. All my music is in a Music Folder and I output the playlist files from rhythmbox into the Music folder so it uses relative indexing (rhythmbox will use relative if it can so all music in the playlist is contained in that music folder. If not, it will use absolute paths). Then the same directory structure is set up on the blackberry and music is transferred as well as the same playlists in a format blackberry understands.

I may write a rhythmbox plugin for this if I get time because shouldn't be difficult and would fully automate the process. There may already be an easier way to do this I just didn't find one relatively quickly.

Note: If it uses absolute paths so my setup above isn't followed the script would need to be slightly modified.


USAGE:
  1. Change dirBlackMusic to the blackberry mount location (should be '/media/???????/BlackBerry/music/' where ?????? is whatever your system decides)
  2. Change dirCompMusic to your music folder
  3. Set-up so you input playlist without the .m3u etension (make sure to output playlists from rhythmbox as .m3u) and if you just hit enter and input nothing it runs the playlists set in listPlaylist
  4. Note: dirPlayNameBlack was for absolute paths on blackberry but currently not using it in the script because using relative on PC and blackberry.


Need to comment the code below but any questions just ask.

Code:
import os
import shutil

def ensureDir(f):
    d = os.path.dirname(f)
    if not os.path.exists(d):
        os.makedirs(d)
inputPlaylist = raw_input('Enter Name of Playlist:')
inputPlaylist += '.m3u'
if (inputPlaylist == '.m3u'):
    listPlaylist = ['Blackberry.m3u','Acoust.m3u','Country.m3u','LiamTomTom.m3u','New Great.m3u','PowerHour.m3u','That Stanky Shit.m3u','Other Stuff.m3u'] #Works on spaces properly but need \' and \"
else:
    listPlaylist = inputPlaylist
dirCompMusic = '/mnt/data/Music/'
dirBlackMusic = '/media/424D-549E/BlackBerry/music/'
dirBlackPlaylist = dirBlackMusic
dirPlayNameBlack = 'file:///SDCard/BlackBerry/music'
if (os.path.exists(dirBlackMusic)):  
    for namePlaylist in listPlaylist:
        readPlay = open(namePlaylist, 'r')  
        writePlay = open(dirBlackMusic + namePlaylist, 'w')
        for line in readPlay:
            line = line.strip()
            if (line[0] == '#'):
                pass
            else:
                line = line.replace('"','\"')
                line = line.replace("'","\'")
                dirBlackPath = dirBlackMusic + line
                ensureDir(dirBlackPath)
                if (not os.path.isfile(dirBlackPath)):
                    #ospath = line.replace(' ','\\ ')
                    # os.system("cp %s %s" % (ospath, blackberrypath))
                    shutil.copy(line, dirBlackPath)
                playNameBlack = line.replace(' ','%20')
                writePlay.write(playNameBlack + '\n')
        writePlay.close()
        readPlay.close()
else:
    print "Please Mount your Blackberry or Change dirBlackMusic to reflect music Folder"

Cheers
Offline  
Closed Thread


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

Forum Jump

Similar Threads for: Script to Copy/Sync Playlists and Music to Blackberry
Thread Thread Starter Forum Replies Last Post
New Blackberry Torch Announced tsac General 9800 Series Discussion - Torch 4 08-03-2010 02:43 PM
More iPhone vs. BB djm2 BlackBerry Versus 116 07-17-2008 09:42 PM
AT&T Blackberry Curve dirtypirate General 8300 Series Discussion - Curve 7 09-30-2007 05:00 PM
RIM Introduces the BlackBerry Curve Smartphone BlackBerryLinks BlackBerry In the News 0 05-03-2007 03:47 AM


Branson 902J Ultrasonic Welder  Transducer Amplifier & Horn 101149098,416026021 picture

Branson 902J Ultrasonic Welder Transducer Amplifier & Horn 101149098,416026021

$599.00



NEW Mitsubishi Servo Amplifier MR-J2S-500B4 Servo Drive picture

NEW Mitsubishi Servo Amplifier MR-J2S-500B4 Servo Drive

$3685.50



KEYENCE CORP DD-860 Amplifier Unit 2 Head Type 50 Ms Response Time picture

KEYENCE CORP DD-860 Amplifier Unit 2 Head Type 50 Ms Response Time

$299.00



Adafruit Audio IC Development Tools Adafruit Mono 2.5W Class D Audio Amplifier - picture

Adafruit Audio IC Development Tools Adafruit Mono 2.5W Class D Audio Amplifier -

$5.95



GPS signal amplifier repeater GPS signal booster indoor signal coverage 1568RF picture

GPS signal amplifier repeater GPS signal booster indoor signal coverage 1568RF

$287.99



SKAR AUDIO USED SK-M4004D 400 WATT 4-CHANNEL CLASS D MINI CAR AMPLIFIER picture

SKAR AUDIO USED SK-M4004D 400 WATT 4-CHANNEL CLASS D MINI CAR AMPLIFIER

$114.99







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.