]> git.rkrishnan.org Git - functorrent.git/blobdiff - src/Main.hs
project renamed to "functorrent"
[functorrent.git] / src / Main.hs
index 10aa2874a4eaac64489c914dea40bf23c14739c9..14656d12689135c477c5bf60a8ffef2d0b787172 100644 (file)
@@ -7,6 +7,7 @@ import qualified Bencode as Benc
 import qualified Metainfo as MInfo
 import qualified Tracker as T
 import qualified Text.ParserCombinators.Parsec as Parsec
+import qualified Peer as P
 import Data.Functor
 
 printError :: Parsec.ParseError -> IO ()
@@ -19,7 +20,7 @@ exit :: IO BC.ByteString
 exit = exitWith ExitSuccess
 
 usage :: IO ()
-usage = putStrLn "usage: deluge torrent-file"
+usage = putStrLn "usage: functorrent torrent-file"
 
 parse :: [String] -> IO (BC.ByteString)
 parse [] = usage >> exit
@@ -34,7 +35,7 @@ main = do
    Right d -> case (MInfo.mkMetaInfo d) of
                Nothing -> putStrLn "parse error"
                Just m -> do
-                 body <- (Benc.decode . BC.pack) <$> T.connect (MInfo.announce m) (T.prepareRequest d genPeerId)
-                 putStrLn (show body)
+                 body <- BC.pack <$> T.connect (MInfo.announce m) (T.prepareRequest d genPeerId)
+                 putStrLn (show (P.getPeers (P.getPeerResponse body)))
    Left e -> printError e
   putStrLn "done"