Portability | not portable |
---|---|
Stability | unstable |
Maintainer | Joachim Fasting <joachim.fasting@gmail.com> |
Bindings to libmtp. High-level interface.
Usage:
import qualified MTP
main = do
MTP.init
MTP.withFirstDevice MTP.getDeviceVersion
- data MTPHandle
- data Track = Track {
- trackID :: Int
- trackParentID :: Int
- trackStorageID :: Int
- trackTitle :: String
- trackArtist :: String
- trackComposer :: String
- trackGenre :: String
- trackAlbum :: String
- trackDate :: String
- trackFileName :: String
- trackNumber :: Int
- trackDuration :: Int
- trackSamplerate :: Int
- trackChannels :: Int
- trackWavecodec :: Int
- trackBitrate :: Int
- trackBitrateType :: Int
- trackRating :: Int
- trackUseCount :: Int
- trackFileSize :: Integer
- trackFileType :: FileType
- data File = File {}
- data Folder = Folder {
- folderID :: Int
- folderParentID :: Int
- folderStorageID :: Int
- folderName :: String
- folderChild :: Maybe Folder
- data Playlist = Playlist {}
- data FileType
- data MTPException
- = NoDevice
- | StorageFull
- | ConnectionFailed
- | Cancelled
- | General String
- version :: Integer
- wav :: FileType
- mp3 :: FileType
- wma :: FileType
- ogg :: FileType
- audible :: FileType
- mp4 :: FileType
- undef_audio :: FileType
- wmv :: FileType
- avi :: FileType
- mpeg :: FileType
- asf :: FileType
- qt :: FileType
- undef_video :: FileType
- jpeg :: FileType
- jfif :: FileType
- tiff :: FileType
- bmp :: FileType
- gif :: FileType
- pict :: FileType
- png :: FileType
- vcalendar1 :: FileType
- vcalendar2 :: FileType
- vcard2 :: FileType
- vcard3 :: FileType
- windowsimageformat :: FileType
- winexec :: FileType
- text :: FileType
- html :: FileType
- firmware :: FileType
- aac :: FileType
- mediacard :: FileType
- flac :: FileType
- mp2 :: FileType
- m4a :: FileType
- doc :: FileType
- xml :: FileType
- xls :: FileType
- ppt :: FileType
- mht :: FileType
- jp2 :: FileType
- unknown :: FileType
- init :: IO ()
- getFirstDevice :: IO MTPHandle
- releaseDevice :: MTPHandle -> IO ()
- resetDevice :: MTPHandle -> IO ()
- withFirstDevice :: (MTPHandle -> IO a) -> IO a
- getDeviceVersion :: MTPHandle -> IO String
- getManufacturerName :: MTPHandle -> IO String
- getModelName :: MTPHandle -> IO String
- getSerialNumber :: MTPHandle -> IO String
- getFriendlyName :: MTPHandle -> IO String
- getBatteryLevel :: MTPHandle -> IO (Int, Int)
- getSupportedFileTypes :: MTPHandle -> IO [FileType]
- getFileListing :: MTPHandle -> IO [File]
- getFile :: MTPHandle -> Int -> FilePath -> IO ()
- sendFile :: MTPHandle -> FilePath -> IO ()
- hGetFile :: MTPHandle -> Int -> Handle -> IO ()
- hSendFile :: MTPHandle -> Handle -> File -> IO ()
- setFileName :: MTPHandle -> File -> String -> IO ()
- emptyTrack :: Track
- doesTrackExist :: MTPHandle -> Int -> IO Bool
- getTrackListing :: MTPHandle -> IO [Track]
- getTrack :: MTPHandle -> Int -> FilePath -> IO ()
- sendTrack :: MTPHandle -> FilePath -> Track -> IO ()
- hGetTrack :: MTPHandle -> Int -> Handle -> IO ()
- hSendTrack :: MTPHandle -> Handle -> Track -> IO ()
- updateTrack :: MTPHandle -> Track -> IO ()
- getTrackMetadata :: MTPHandle -> Int -> IO (Maybe Track)
- setTrackName :: MTPHandle -> Track -> String -> IO ()
- createFolder :: MTPHandle -> String -> Int -> Int -> IO Int
- getFolderList :: MTPHandle -> IO [Folder]
- setFolderName :: MTPHandle -> Folder -> String -> IO ()
- getPlaylistList :: MTPHandle -> IO [Playlist]
- getPlaylist :: MTPHandle -> Int -> IO (Maybe Playlist)
- createPlaylist :: MTPHandle -> Playlist -> IO ()
- updatePlaylist :: MTPHandle -> Playlist -> IO ()
- setPlaylistName :: MTPHandle -> Playlist -> String -> IO ()
- deleteObject :: MTPHandle -> Int -> IO ()
- setObjectName :: MTPHandle -> Int -> String -> IO ()
- findFileType :: FilePath -> FileType
Types
Track metadata.
Track | |
|
File metadata.
Folder metadata.
Folder | |
|
Playlist metadata.
Playlist | |
|
data MTPException Source
MTP exceptions.
Constants
Device management
getFirstDevice :: IO MTPHandleSource
Connect to the first available MTP device.
releaseDevice :: MTPHandle -> IO ()Source
Close connection to a MTP device. The handle is unusable after this.
resetDevice :: MTPHandle -> IO ()Source
Reset device.
withFirstDevice :: (MTPHandle -> IO a) -> IO aSource
Open a connection to the first available MTP device and run an action, closing the connection afterwards.
getDeviceVersion :: MTPHandle -> IO StringSource
Get device hardware and firmware version.
getManufacturerName :: MTPHandle -> IO StringSource
Get the device manufacturer name.
getModelName :: MTPHandle -> IO StringSource
Get the device model name.
getSerialNumber :: MTPHandle -> IO StringSource
Get the device serial number.
getFriendlyName :: MTPHandle -> IO StringSource
Get the owner string aka. the "friendly name".
getSupportedFileTypes :: MTPHandle -> IO [FileType]Source
Get a list of supported file types.
File management
getFileListing :: MTPHandle -> IO [File]Source
Get a list of all files stored on the device.
hSendFile :: MTPHandle -> Handle -> File -> IO ()Source
Send a file to the device from a file handle.
Track management
An empty track.
getTrackListing :: MTPHandle -> IO [Track]Source
Get a list of all tracks stored on the device.
getTrack :: MTPHandle -> Int -> FilePath -> IO ()Source
Copy a track from the device to a local file.
sendTrack :: MTPHandle -> FilePath -> Track -> IO ()Source
Send a local track to the device, using the supplied metadata.
hGetTrack :: MTPHandle -> Int -> Handle -> IO ()Source
Copy a track from the device to a file handle.
hSendTrack :: MTPHandle -> Handle -> Track -> IO ()Source
Send a track to the device from a file handle.
Folder management
Create a new folder.
getFolderList :: MTPHandle -> IO [Folder]Source
Get a list of all folders on the device.
Audio/video playlist management
getPlaylistList :: MTPHandle -> IO [Playlist]Source
Get a list of playlists on the device.
createPlaylist :: MTPHandle -> Playlist -> IO ()Source
Create a new playlist using the metadata supplied.
setPlaylistName :: MTPHandle -> Playlist -> String -> IO ()Source
Rename an existing playlist. The expected name suffix is ".pla".
Object management
deleteObject :: MTPHandle -> Int -> IO ()Source
Delete a single file, track, playlist, folder or any other object.
Extras
findFileType :: FilePath -> FileTypeSource
Find the FileType for a given file name.