tOodiName :: Text         -- ^ 'Text' containing a raw version of the 'Course' name.
            -> Maybe Text   -- ^ The Unicode formatted version of the 'Course' name.
getOodiName =
    fmap (T.pack
          . sub "&aring;" "å"
          . sub "&Aring;" "Å"
          . sub "&auml;" "ä"
          . sub "&Auml;" "Ä"
          . sub "&ouml;" "ö"
          . sub "&Ouml;" "Ö"
          . sub "&#x3a;" ":"
          . sub "&#x27;" "'"
          . sub "&#x28;" "("
          . sub "&#x29;" ")"
          . sub "&#x3b;" ";"
          . head) . matchRegex (mkRegexWithOpts s True False) . T.unpack
  where
    s         = "tauluotsikko\"?>[0-9 ]*(.*),[^,]*<"
    sub a b i = subRegex (mkRegexWithOpts a False True) i b


-- TODO: Move this into the 'webOodiLink' function
{- | Helper method to select the correct 'Lang'uage when using WebOodi. The
    'Lang'uage is changed by switching a number in the URL:

        * 1 : fi (Finnish version)

        * 2 : se (Swedish version)

        * 6 : en (English version)

    If another 'Lang'uage than the provided ones is used, the function returns
    an empty 'String' instead of a 'Num'ber.
-}
weboodi
getOodiName :: Text         -- ^ 'Text' containing a raw version of the 'Course' name.
            -> Maybe Text
getOodiName =
    fmap (T.pack
          . sub "&aring;" "å"
          . sub "&Aring;" "Å"
          . sub "&auml;" "ä"
          . sub "&Auml;" "Ä"
          . sub "&ouml;" "ö"
          . sub "&Ouml;" "Ö"
          . sub "&#x3a;" ":"
          . sub "&#x27;" "'"
          . sub "&#x28;" "("
          . sub "&#x29;" ")"
          . sub "&#x3b;" ";"
          . head) . matchRegex (mkRegexWithOpts s True False) . T.unpack
  where
    s         = "tauluotsikko\"?>[0-9 ]*(.*),[^,]*<"
    sub a b i = subRegex (mkRegexWithOpts a False True) i b


-- TODO: Move this into the 'webOodiLink' function
{- | Helper method to select the correct 'Lang'uage when using WebOodi. The
    'Lang'uage is changed by switching a number in the URL:

        * 1 : fi (Finnish version)

        * 2 : se (Swedish version)

        * 6 : en (English version)

    If another 'Lang'uage than the provided ones is used, the function returns
    an empty 'String' instead of a 'Num'ber.
-}
getOodiName =
    fmap (T.pack
          . sub "&aring;" "å"
          . sub "&Aring;" "Å"
          . sub "&auml;" "ä"
          . sub "&Auml;" "Ä"
          . sub "&ouml;" "ö"
          . sub "&Ouml;" "Ö"
          . sub "&#x3a;" ":"
          . sub "&#x27;" "'"
          . sub "&#x28;" "("
          . sub "&#x29;" ")"
          . sub "&#x3b;" ";"
          . head) . matchRegex (mkRegexWithOpts s True False) . T.unpack
  where
    s         = "tauluotsikko\"?>[0-9 ]*(.*),[^,]*<"
    sub a b i = subRegex (mkRegexWithOpts a False True) i b


-- TODO: Move this into the 'webOodiLink' function
{- | Helper method to select the correct 'Lang'uage when using WebOodi. The
    'Lang'uage is changed by switching a number in the URL:

        * 1 : fi (Finnish version)

        * 2 : se (Swedish version)

        * 6 : en (English version)

    If another 'Lang'uage than the provided ones is used, the function returns
    an empty 'String' instead of a 'Num'ber.
-}