pgdl 8.3 → 8.4
raw patch · 6 files changed
+49/−26 lines, 6 filesdep +http-conduit
Dependencies added: http-conduit
Files
- README.md +16/−6
- pgdl.cabal +5/−4
- src/FetchHtml.hs +6/−4
- src/Pgdl.hs +11/−11
- src/PrsVid.hs +1/−1
- src/UI.hs +10/−0
README.md view
@@ -6,22 +6,32 @@ Client: Only for Linux and MACOSX. Server: Only for nginx's file download page. -The program will sort the video files and folders by date while files in nginx's download page just sort by name.+The program will sort files and folders by date while files in nginx's download page just sort by name. ## Installing +```shell cabal update cabal install pgdl+``` +If there is an error occured when installing vty-ui, you may need +```shell+cabal install vty-ui -f no-tests +```++to skip build of testing executable.+ ## Shortcut keys q - quit -s - list files that similar with the highlighted video -Key Right - show the detailed information of the highlighted video +s - list files that similar with the highlighted file+Key Right - show the detailed information of the highlighted file Key Left - go back to the previous page -Enter - play the video +Enter - xdg-open the file / - open a input box to enter a keyword to search n - sort the current list by name -v - show the videos already in the disk -u - show the videos not in the disk+v - show the filess already in the disk +u - show the filess not in the disk +h - shortcut keys' help page
pgdl.cabal view
@@ -1,6 +1,6 @@ name: pgdl-version: 8.3+version: 8.4 license: PublicDomain license-file: LICENSE author: sifmelcara@@ -9,7 +9,7 @@ build-type: Simple extra-source-files: README.md cabal-version: >=1.10-description: a terminal user interface program downloads video from nginx file index page and play it.+description: a terminal user interface program downloads video (or a file) from nginx file index page and xdg-open it. (Linux: xdg-open "video.mp4", MACOSX: open "video.mp4") . Client: Only for Linux and MACOSX.@@ -17,7 +17,7 @@ . The program will sort the files and folders by date while files in nginx's download page just sort by name. .- For shortcut keys, please visit <https://github.com/sifmelcara/pgdl>+ For shortcut keys, please visit <https://github.com/sifmelcara/pgdl> or press h in the program. synopsis: simply download a video (or a file) from a webpage and xdg-open it. @@ -36,7 +36,8 @@ tagsoup, network-uri, vty, text, vty-ui >= 1.9, configurator >= 0.3.0.0, HTTP,- filepath, Cabal, array+ filepath, Cabal, array,+ http-conduit < 3.0.0 ghc-options: -threaded -O2 default-language: Haskell2010
src/FetchHtml.hs view
@@ -4,13 +4,15 @@ import Getconfig -import Network.HTTP import Network.URI import Data.Text.Encoding import Data.Maybe import System.FilePath import Control.Applicative import qualified Data.Text as T+import Network.HTTP.Conduit+import Data.ByteString.Lazy+--import bytestring? fetchHtml :: IO T.Text fetchHtml = getTextContent =<< genURI@@ -30,8 +32,8 @@ getTextContent :: String -> IO T.Text getTextContent u = do- res <- simpleHTTP . mkRequest GET . fromJust . parseURI $ u- cnt <- getResponseBody res- return $ decodeUtf8 cnt+ bs <- simpleHttp u+ let t = decodeUtf8 . toStrict $ bs+ return t
src/Pgdl.hs view
@@ -119,11 +119,11 @@ removeVid itm chgls - onSelectionChange lst $ \sle -> case sle of- SelectionOn _ itm _ -> setText statBar =<< genStat itm- -- refresh state bar after any scroll- _ -> return ()- + -- onSelectionChange lst $ \sle -> case sle of+ -- SelectionOn _ itm _ -> setText statBar =<< genStat itm+ -- -- refresh state bar after any scroll+ -- _ -> return ()+ refreshStatusBar lst statBar let chgInf = do Just (_, (vid, _)) <- getSelected lst@@ -200,7 +200,7 @@ else return False return True KChar 'u' -> do- filterVListIO vlst $ \obj -> if isVid obj then not <$> (downloaded obj)+ filterVListIO vlst $ \obj -> if isVid obj then not <$> downloaded obj else return False return True KChar '/' -> do@@ -222,14 +222,14 @@ helpPage :: T.Text helpPage = T.unlines [ "q - quit"- ,"s - list files that similar with the highlighted video"- ,"Key Right - show the detailed information of the highlighted video"+ ,"s - list files that similar with the highlighted file"+ ,"Key Right - show the detailed information of the highlighted file" ,"Key Left - go back to the previous page"- ,"Enter - play the video"+ ,"Enter - xdg-open the file" ,"/ - open a input box to enter a keyword to search" ,"n - sort the current list by name"- ,"v - show the videos already in the disk"- ,"u - show the videos not in the disk"+ ,"v - show all the files already in the disk"+ ,"u - show all the files not in the disk" ]
src/PrsVid.hs view
@@ -19,7 +19,7 @@ filter isVidLn . map parseTags . T.lines where isVidLn = any isVidLnk isVidLnk tg- | isTagOpen tg = (not $ "/" `T.isSuffixOf` fromAttrib "href" tg) && (not . T.null $ fromAttrib "href" tg)+ | isTagOpen tg = not ("/" `T.isSuffixOf` fromAttrib "href" tg) && (not . T.null $ fromAttrib "href" tg) | otherwise = False pullText tg | isTagOpen tg = fromAttrib "href" tg
src/UI.hs view
@@ -7,6 +7,7 @@ import Video import RealWorld import NameAlgo+import GenStat import Control.Monad import System.Exit@@ -137,6 +138,15 @@ -- if video have been download, use red color False -> setFocusAttribute lst (black `on` cyan) -- if video haven't been download, use cyan+ threadDelay 50000 -- 0.05 second+ return ()++refreshStatusBar :: WL -> Widget FormattedText-> IO ()+refreshStatusBar lst statBar = do+ forkIO . forever $ do+ schedule $ do+ Just (_, (itm, _)) <- getSelected lst+ setText statBar =<< genStat itm threadDelay 50000 -- 0.05 second return ()