summaryrefslogtreecommitdiff
path: root/src/Data/Torrent.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Data/Torrent.hs')
-rw-r--r--src/Data/Torrent.hs9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/Data/Torrent.hs b/src/Data/Torrent.hs
index 128c1c7c..57831acf 100644
--- a/src/Data/Torrent.hs
+++ b/src/Data/Torrent.hs
@@ -2,7 +2,8 @@
2{-# LANGUAGE OverloadedStrings #-} 2{-# LANGUAGE OverloadedStrings #-}
3-- | This module provides torrent metainfo serialization. 3-- | This module provides torrent metainfo serialization.
4module Data.Torrent 4module Data.Torrent
5 ( Torrent(..), TorrentInfo(..), TorrentFile(..) 5 ( module Data.Torrent.InfoHash
6 , Torrent(..), TorrentInfo(..), TorrentFile(..)
6 , fromFile 7 , fromFile
7 ) where 8 ) where
8 9
@@ -13,8 +14,8 @@ import Data.ByteString (ByteString)
13import qualified Data.ByteString as B 14import qualified Data.ByteString as B
14import qualified Data.ByteString.Char8 as BC (pack, unpack) 15import qualified Data.ByteString.Char8 as BC (pack, unpack)
15import Data.Text (Text) 16import Data.Text (Text)
16import Crypto.Hash.SHA1
17import Data.BEncode 17import Data.BEncode
18import Data.Torrent.InfoHash
18import Network.URI 19import Network.URI
19 20
20type Time = Text 21type Time = Text
@@ -22,7 +23,7 @@ type Time = Text
22-- TODO comment fields 23-- TODO comment fields
23-- TODO more convenient form of torrent info. 24-- TODO more convenient form of torrent info.
24data Torrent = Torrent { 25data Torrent = Torrent {
25 tInfoHash :: ByteString 26 tInfoHash :: InfoHash
26 , tAnnounce :: URI 27 , tAnnounce :: URI
27 , tAnnounceList :: Maybe [[URI]] 28 , tAnnounceList :: Maybe [[URI]]
28 , tComment :: Maybe Text 29 , tComment :: Maybe Text
@@ -148,4 +149,4 @@ instance BEncodable TorrentFile where
148 149
149 150
150fromFile :: FilePath -> IO (Result Torrent) 151fromFile :: FilePath -> IO (Result Torrent)
151fromFile path = (fromBEncode <=< decode) <$> B.readFile path 152fromFile filepath = (fromBEncode <=< decode) <$> B.readFile filepath