Modyfikacja parametru originalDate

This commit is contained in:
Rafał Sobański 2021-04-07 12:10:27 +02:00
parent 1c5fe464b3
commit 11683b816c
10 changed files with 9 additions and 4 deletions

0
.Rhistory Normal file
View File

View File

@ -1,4 +1,4 @@
/home/arab/tajemnica-atari/shadow-library.cabal: /home/arab/tajemnica-atari/shadow-library.cabal:
hash: 714bd61ef22b868b423c5ab32edbbca76e241ecb2075dced142701878c34217a hash: 714bd61ef22b868b423c5ab32edbbca76e241ecb2075dced142701878c34217a
/home/arab/tajemnica-atari/app/tajemnicaatari.hs: /home/arab/tajemnica-atari/app/tajemnicaatari.hs:
hash: bddee13012273b21b906bb8fbd691a21a711b4572235a59201b82b3843f2c862 hash: d6d30253647c843a66123cc3a966da1ec5db47b670cfbccc24a2b7289493980c

Binary file not shown.

View File

@ -19,7 +19,7 @@ stack install
Wynikiem pracy robota będzie zbiór elementów ShadowItem. Oto przypładowy rekord ShadowItem: Wynikiem pracy robota będzie zbiór elementów ShadowItem. Oto przypładowy rekord ShadowItem:
``` ```
ShadowItem {url = Just "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/3_91/3_91_offline.zip", title = "Tajemnica Atari TA 3/91 DjVu OFFLINE (plik ZIP, 1.6MB)", itype = "periodical", originalDate = Just "3_91", creator = Nothing, format = Just "zip", lang = Just "pol", finalUrl = "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/3_91/3_91_offline.zip", description = Nothing} ShadowItem {url = Just "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/4_91/4_91_offline.zip", title = "Tajemnica Atari TA 4/91 DjVu OFFLINE (plik ZIP, 1.9MB)", itype = "periodical", originalDate = Just "1991-4", creator = Nothing, format = Just "zip", lang = Just "pol", finalUrl = "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/4_91/4_91_offline.zip", description = Nothing}
``` ```

View File

@ -0,0 +1 @@
https://git.wmi.amu.edu.pl/s470627/tajemnica-atari

View File

@ -11,6 +11,8 @@ import Data.List.Utils (replace)
import Text.Regex.Posix import Text.Regex.Posix
import Text.Printf import Text.Printf
import Data.List.Utils
extractRecords = extractLinksWithText "//a[@class='ramka']" -- pary adres-tytuł extractRecords = extractLinksWithText "//a[@class='ramka']" -- pary adres-tytuł
@ -20,19 +22,21 @@ extractRecords = extractLinksWithText "//a[@class='ramka']" -- pary adres-tytu
toShadowItem :: ((String, String), String) -> ShadowItem toShadowItem :: ((String, String), String) -> ShadowItem
toShadowItem ((url, articleTitle), yearlyTitle) = toShadowItem ((url, articleTitle), yearlyTitle) =
(defaultShadowItem url title) { (defaultShadowItem url title) {
originalDate = Just date, originalDate = Just newFormatDate,
itype = "periodical", itype = "periodical",
format = Just "zip", format = Just "zip",
finalUrl = url finalUrl = url
} }
where title = "Tajemnica Atari " ++ yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" articleTitle)) where title = "Tajemnica Atari " ++ yearlyTitle ++ " " ++ (replace "\r\n" "" (replace "\r\n " "" articleTitle))
date = getDate url date = getDate url
splitDate = split "_" date
newFormatDate = "19" ++ splitDate !! 1 ++ "-" ++splitDate !! 0
getDate url = getDate url =
case url =~~ "/([1-9]_9[0-9]|1[0-2]_9[0-9]|[1-9]-[1-9]_9[0-9]|1[0-2]-1[0-2]_9[0-9])/" :: Maybe [[String]] of case url =~~ "/([1-9]_9[0-9]|1[0-2]_9[0-9]|[1-9]-[1-9]_9[0-9]|1[0-2]-1[0-2]_9[0-9])/" :: Maybe [[String]] of
Just [[_, year]] -> year Just [[_, year]] -> year
otherwise -> error $ "unexpected url: " ++ url otherwise -> error $ "unexpected url: " ++ url
main = do main = do
let start = "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/" let start = "http://krap.pl/mirrorz/atari/horror.mirage.com.pl/pixel/"