Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[HOWTO] Transfer files to MTP devices using CVS libmtp
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message
saffron1
n00b
n00b


Joined: 04 Nov 2005
Posts: 12
Location: Redmond, Wa

PostPosted: Fri Feb 24, 2006 2:15 am    Post subject: [HOWTO] Transfer files to MTP devices using CVS libmtp Reply with quote

Hello,

Not so much a how to but a quick dirty guide to help people suffering from microsofts monopolistic tactic "Media Transfer Protocol". In brief, it is a slight modification to Picture Transfer Protocol. I was shocked to find this out after buying a 'Creative Zen Vision' yesterday that it was crippled to use only Microsoft, I had read many sources that mislead me. Anywho two gentlemen, Richard A. Low and Linus Walleij have pioneered a project called libmtp http://libmtp.sourceforge.net/

I was lucky that they created an expample client to work with said lib that day. I'm being brief because this is an early project and undoubtably there will be many changes and many third-party programs designed to work with libmtp.

1. First off grab yourself a copy
Code:

$cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/libmtp login
$cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/libmtp co -P libmtp

Enter the new libmtp dir. The included readme said to run
Code:

CC=gcc32
export CC
./configure
make

I did for good measure, there was no configure script so you will need to run
Code:

$./autogen.sh

Now when I ran the configure script I got an error that it couldn't find libusb even after I set and exported the LDFLAGS for it, running it as root in another terminal it worked fine. (any insight as to why?)
then after 'make' you can find the example client in the 'examples' dir (fitting isn't it?)
Hopfully after you run ./detect you will get something like this:
Code:

tribalsun examples # ./detect
PTP: Opening session
Connected to MTP device.
Model: Creative Zen Vision
Serial number: 00023C01EC43A89FCB62880ECE3521F2
Device version: 1.10.08_0.00.15
Maximum battery level: 255
Owner name: Saffron
PTP: Closing session
OK.

I havn't checked out the sendtr program that much but here is an example:
Code:

./sendtr -t 'Back Then' -a 'Mike Jones' -l 'Who Is Mike Jones?' -c mp3 -g Rap -n 02 -d 245 102-mike_jones-back_then.mp3


Well anyway please let me know if this has helped you or if you have any tips. I _may_ get around to making a shell script to transfer all my music. I hate that its not a UMS device and that I cant just rip my CD's direct and that the ID3 type info needs to be specifed. With the active development I think that there will probobly be robust libmtp clients soon.


Cheers,
Saffron
Back to top
View user's profile Send private message
saffron1
n00b
n00b


Joined: 04 Nov 2005
Posts: 12
Location: Redmond, Wa

PostPosted: Sat Feb 25, 2006 1:20 am    Post subject: Reply with quote

Here is a one liner I have been using to add all mp3's in a dir with the id3 info

Code:
mp3info -p "sleep 1;./sendtr -t '%t' -a '%a' -l '%l' -c mp3 -g '%g' -n '%n' -d '%S' -y '%y' '%f';" *.mp3|sh


The catch is you have to modify sendtr.c to accept year info from the command line. (I suspect this functionality will be included soon.)
(sleep my not be nessisiary depending on your device)
My problem is that my device needs to either be reset or unpluged/repluged to accept any file transfer after the first. I would like to add thousands of songs and that problem breaks my automation. There is so many places the problem could exsist I don't know where to begin. Anyone else out there have a MTP crippled player?

Saffron
Back to top
View user's profile Send private message
djselbeck
n00b
n00b


Joined: 10 Oct 2005
Posts: 32
Location: Germany

PostPosted: Sat Mar 04, 2006 2:11 am    Post subject: Reply with quote

You could even try my small GTK application called MTPdude but i dont know if it runs on gentoo. www.sf.net/projects/mtpdude
Back to top
View user's profile Send private message
elsphinc
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 139
Location: Lake Tahoe

PostPosted: Sun Mar 05, 2006 12:49 am    Post subject: trouble with MTPDude Reply with quote

ok so ive got libmtp-0.0.1 installed fine but i cant seem to get MTPDude installed

Code:
In file included from functions.h:16,
                 from main.c:13:
/usr/local/include/libmtp.h:16:23: mtp-utils.h: No such file or directory
In file included from functions.h:16,
                 from main.c:13:
/usr/local/include/libmtp.h:62: error: syntax error before "uint8_t"
/usr/local/include/libmtp.h:64: error: syntax error before '*' token
/usr/local/include/libmtp.h:66: error: syntax error before "maximum_battery_level"
/usr/local/include/libmtp.h:73: error: syntax error before "uint32_t"
/usr/local/include/libmtp.h:80: error: syntax error before "tracknumber"
/usr/local/include/libmtp.h:81: error: syntax error before "duration"
/usr/local/include/libmtp.h:82: error: syntax error before "filesize"
/usr/local/include/libmtp.h:85: error: syntax error before '}' token
/usr/local/include/libmtp.h:104: error: syntax error before "const"
/usr/local/include/libmtp.h:120: error: syntax error before "uint64_t"
/usr/local/include/libmtp.h:124: error: syntax error before "uint8_t"
/usr/local/include/libmtp.h:134: error: syntax error before "uint32_t"
/usr/local/include/libmtp.h:136: error: syntax error before "uint32_t"
/usr/local/include/libmtp.h:148: error: syntax error before "uint32_t"
In file included from main.c:13:
functions.h:66: error: syntax error before "uint32_t"
functions.h:66: warning: no semicolon at end of struct or union
functions.h:75: error: syntax error before '}' token
main.c: In function `end':
main.c:44: error: dereferencing pointer to incomplete type
main.c: In function `deviceinfodialog':
main.c:64: error: dereferencing pointer to incomplete type
main.c: In function `main':
main.c:115: error: invalid application of `sizeof' to incomplete type `functions.h'
main.c:123: error: dereferencing pointer to incomplete type
main.c:155: error: dereferencing pointer to incomplete type
main.c:157: error: dereferencing pointer to incomplete type
main.c:158: error: dereferencing pointer to incomplete type
main.c:160: error: dereferencing pointer to incomplete type
main.c:118: warning: unused variable `infodialog'
make[2]: *** [main.o] Error 1
make[2]: Leaving directory `/usr/local/MTPdude-0.1unstable_PREVIEW/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/MTPdude-0.1unstable_PREVIEW'
make: *** [all] Error 2


whereis tells me i've got a /usr/local/include/libmtp.h

any ideas

Thanks

EDIT: Ok so i copied over the headers from src/ to /usr/local/include and i was able to get mtpdude to install
_________________
elsphinc # kickin_ass &
mysql> create database namesdb;


Last edited by elsphinc on Sun Mar 05, 2006 1:32 am; edited 1 time in total
Back to top
View user's profile Send private message
saffron1
n00b
n00b


Joined: 04 Nov 2005
Posts: 12
Location: Redmond, Wa

PostPosted: Sun Mar 05, 2006 1:24 am    Post subject: Reply with quote

Hi elsphinc, I was writing a reply but then I relized I already replied to you on the sourceforge forum. I hope it helps!
Back to top
View user's profile Send private message
elsphinc
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 139
Location: Lake Tahoe

PostPosted: Sun Mar 05, 2006 1:33 am    Post subject: Reply with quote

thats pretty funny, thanks for your prompt response
_________________
elsphinc # kickin_ass &
mysql> create database namesdb;
Back to top
View user's profile Send private message
saffron1
n00b
n00b


Joined: 04 Nov 2005
Posts: 12
Location: Redmond, Wa

PostPosted: Sat Mar 18, 2006 1:41 am    Post subject: Reply with quote

this post is getting pretty obsolete, When I wrote this there wasn't any 3rd party clients for libmtp.
Now I belive there is two:
One mentioned earlier: MTPdude (GTK app) by djselbeck http://sourceforge.net/projects/mtpdude/
Or mine id34mtp (console): http://sourceforge.net/projects/id34mtp

Have Fun,
Saffron
Back to top
View user's profile Send private message
trupoet
Apprentice
Apprentice


Joined: 08 Aug 2002
Posts: 160

PostPosted: Wed May 17, 2006 4:23 pm    Post subject: Reply with quote

Has anyone gotten MTPDude to compile? I've tried 0.0.5, 0.0.6 and the latest from CVS with no luck...some kind of error about too few arguments to a certain function.
Back to top
View user's profile Send private message
elsphinc
Tux's lil' helper
Tux's lil' helper


Joined: 24 Oct 2002
Posts: 139
Location: Lake Tahoe

PostPosted: Thu May 18, 2006 5:31 pm    Post subject: nope Reply with quote

no luck here from version 0.0.1 to 0.0.6. I gave up on it and just went with the new gnomad-2.8.3 which has mtp support and has a fairly intuitive interface. The dude looked like it had potential if you can even get it installed.
_________________
elsphinc # kickin_ass &
mysql> create database namesdb;
Back to top
View user's profile Send private message
trupoet
Apprentice
Apprentice


Joined: 08 Aug 2002
Posts: 160

PostPosted: Thu May 18, 2006 6:58 pm    Post subject: Reply with quote

Finally got it to compile. Havent tested it yet. But basically I found out it needed libmtp 0.0.3 to use MTPDude 0.0.6.
Back to top
View user's profile Send private message
RattyMan
Tux's lil' helper
Tux's lil' helper


Joined: 12 Apr 2004
Posts: 79

PostPosted: Fri Jun 02, 2006 10:30 pm    Post subject: Reply with quote

I have just tried gnomad 2.8.5 and this is working (partially) with libmtp 0.0.6. I have created a basic ebuild based on libptp for libmtp:

Code:
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

inherit eutils

DESCRIPTION="Library communicating with MTP enabled devices."
HOMEPAGE="http://libmtp.sourceforge.net/"
SRC_URI="mirror://sourceforge/libmtp/${P}.tar.gz"
LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
IUSE=""
RDEPEND=">=dev-libs/libusb-0.1.8"
DEPEND="${RDEPEND}"


and I have used the existing Gnomad ebuild just renamed for 2.8.5 in an overlay.

The issues that I am having at the moment is mainly transfering data and / or folders, gnomad seems to segfault.
Also, I only seem to be able to run as root, anyone got any ideas??

RattyMan
Back to top
View user's profile Send private message
msch
Guru
Guru


Joined: 14 Mar 2006
Posts: 385
Location: ms@wind ~ $

PostPosted: Mon Jun 05, 2006 9:28 pm    Post subject: Reply with quote

here are my (first) 2 ebuilds for gnomad 2.8.5 with libmtp-0.0.8:

media-sound/gnomad/gnomad-2.8.5.ebuild
Code:

# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

inherit flag-o-matic gnome2

MY_PN="${PN}2"
MY_P="${MY_PN}-${PV}"
S=${WORKDIR}/${MY_P}

DESCRIPTION="A GNOME2 frontend for Creative Players (Zen, JukeBox, etc ...)"
HOMEPAGE="http://gnomad2.sourceforge.net/"
SRC_URI="mirror://sourceforge/${MY_PN}/${MY_P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
IUSE=""

#-sparc: 2.4.4: Application crashes on startup (Gnome crash detection)
KEYWORDS="~amd64 ~ppc -sparc ~x86"

RDEPEND=">=dev-libs/glib-2.6.0
   >=gnome-base/libgnomeui-2
   >=media-libs/libnjb-2.2.4
   media-libs/libid3tag
   >=gnome-base/gconf-1.2
   media-libs/libmtp"

DEPEND="${RDEPEND}
   >=dev-util/pkgconfig-0.12.0
   >=dev-util/intltool-0.21"

src_compile() {
   ALLOWED_FLAGS=""
   strip-flags

   replace-flags -O3 -O2
   gnome2_src_compile
}

src_install() {
   make DESTDIR="${D}" install || die

   dodoc AUTHORS ChangeLog NEWS README TODO
}


media-libs/libmtp/libmtp-0.0.8.ebuild
Code:

# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $


DESCRIPTION="libmtp is a LGPL library implementation of the Media Transfer Protocol (MTP), a superset of the Picture Transfer Protocol (PTP)."
HOMEPAGE="http://sourceforge.net/projects/libmtp"
SRC_URI="mirror://sourceforge/libmtp/$P.tar.gz"

LICENSE="LGPL"
SLOT="0"
KEYWORDS="~x86"

RDEPEND="dev-libs/libusb"

src_unpack() {
    unpack ${A}
    cd ${S}
}

src_compile() {
    econf || die "econf failed"
    emake -j1 || die "make failed"
}

src_install() {
    make DESTDIR=${D} install || die
    dodoc AUTHORS README TODO
}


just digest it
Back to top
View user's profile Send private message
ekpyrotic
n00b
n00b


Joined: 18 Feb 2005
Posts: 52

PostPosted: Wed Jun 28, 2006 4:33 am    Post subject: Reply with quote

Nicely done. Why don't you submit that ebuild for inclusion to the portage tree?
Back to top
View user's profile Send private message
RattyMan
Tux's lil' helper
Tux's lil' helper


Joined: 12 Apr 2004
Posts: 79

PostPosted: Mon Jul 31, 2006 12:15 am    Post subject: Reply with quote

Has anyone been able to get the latest CVS version of Banshee running with libgphoto2 (SVN) as per the following site:

http://tricky.vanstaveren.us/Projects/Open_Source/Banshee/MTP

I have tried it but cannot get the csharp libgphoto libries to build!
Back to top
View user's profile Send private message
jroo
n00b
n00b


Joined: 06 Mar 2005
Posts: 52
Location: Finland

PostPosted: Sat Aug 19, 2006 11:20 am    Post subject: Reply with quote

I could not get those GUIs to compile and the one liner posted by saffron1 was not enough for me so I wrote a simple python script for uploading tracks form given directory (and all of it's sub directories). It's included below so if anyone needs that kind of script feel free to use it.

The only requirements (beside python itself) is pyid3lib (emerge pyid3lib) and sendtr executable in your path (can be found under examples directory after you have compiled libmtp).

The script sets genre as "" because I was too lazy to find out how to get the string out from id3v2 tag as string (some of the tags were like '(22)', some 'deat metal' and some '(22), death metal'). But anyway this seems to work quite well with my Zen Vision: M

Code:

#!/usr/bin/python
# -*- coding: UTF-8 -*-



import os
import re
import sys
import testoob
import unittest

import pyid3lib

__mp3FileRe = re.compile( "^.*\.mp3$" )


def __findMp3Files( pDirectory = '.' ):
    mp3Files = []
    files = os.listdir( pDirectory )

    for filename in files:
        file = os.path.join( pDirectory, filename )
        if os.path.isdir( file ):
            mp3Files += __findMp3Files( file )
        elif __mp3FileRe.match( filename ):
            currentFilename = os.path.join( pDirectory, filename )
            mp3Files.append( currentFilename )


    return mp3Files


class NotADirectoryError( RuntimeError ):
    def __init__( self, value ):
        self.value = value

    def __str__( self ):
        return repr(self.value)


def uploadMp3sUnderDir( pDirectory = "." ):
    if os.path.isdir( pDirectory ):
        if not os.path.isabs( pDirectory ):
            pDirectory = os.path.abspath( pDirectory )
       
        mp3Files = __findMp3Files( pDirectory )
        for x in mp3Files:
            id3tag = pyid3lib.tag( x )
           
            genre = ""
           
            command = 'sendtr ' + \
                      '-t "' + id3tag.title + '" ' + \
                      '-a "' + id3tag.artist + '" ' + \
                      '-l "' + id3tag.album + '" ' + \
                      '-c mp3 ' + \
                      '-g "' + genre + '" ' + \
                      '-n "' + str( id3tag.track[0] ) + '" ' + \
                      '-y "' + str( id3tag.year ) + '" ' + \
                      '-q ' + \
                      '"' + x + '"'
           
            print command
            os.system( command )
           
    else:
        raise NotADirectoryError, "No such directory: " + pDirectory


if __name__ == '__main__':
    try:
        if len( sys.argv ) == 1:
            uploadMp3sUnderDir()
        else:
            for directory in sys.argv[1:]:
              uploadMp3sUnderDir( directory )
    except NotADirectoryError:
        print "Directory " + sys.argv[1] + " does not exist."

Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum