from typing import Dict, List, Union

MOTLEY_REPLACEMENT = ("&#65533;", "")
TITLE_REPLACEMENTS = ("&raquo;", "»")

A_REL_TAG_SELECTOR = "//a[@rel='tag']"
A_HREF_TAG_SELECTOR = (
    "//a[contains(@href, '/tag/')] | //a[contains(@href, '/tags/')] |"
    " //a[contains(@href, '/topic/')] | //a[contains(@href, '?keyword=')]"
)
RE_LANG = r"^[A-Za-z]{2}$"

AUTHOR_ATTRS = ["name", "rel", "itemprop", "class", "id", "property"]
AUTHOR_VALS = [
    "author",
    "byline",
    "dc.creator",
    "byl",
    "article:author",
    "article:author_name",
    "story-byline",
    "article-author",
    "parsely-author",
    "sailthru.author",
    "citation_author",
]

AUTHOR_STOP_WORDS = [
    "By",
    "Reuters",
    "IANS",
    "AP",
    "AFP",
    "PTI",
    "IANS",
    "ANI",
    "DPA",
    "Senior Reporter",
    "Reporter",
    "Writer",
    "Opinion Writer",
]
TITLE_META_INFO = [
    "dc.title",
    "og:title",
    "headline",
    "articletitle",
    "article-title",
    "parsely-title",
    "title",
]
PUBLISH_DATE_META_INFO = [
    "published_date",
    "published_time",
    "cXenseParse:publishtime",
    "pubdate",
    "publish_date",
    "PublishDate",
    "dcterms.created",
    "rnews:datePublished",
    "article:published_time",
    "prism.publicationDate",
    "displaydate",
    "OriginalPublicationDate",
    "og:published_time",
    "datePublished",
    "article_date_original",
    "article.published",
    "published_time_telegram",
    "sailthru.date",
    "date",
    "Date",
    "original-publish-date",
    "DC.date.issued",
    "dc.date",
    "DC.Date",
    "parsely-pub-date",
    "publishtime",
    "og:regDate",
    "publication_date",
    "uploadDate",
    "coverageEndTime",
    "publishdate",
    "publish-date",
    "publishedAtDate",
    "dcterms.date",
    "publishedDate",
    "creationDateTime",
    "pub_date",
    "updated_time",
    "og:updated_time",
    "datemodified",
    "last-modified",
    "Last-Modified",
    "DC.date.modified",
    "article:modified_time",
    "modified_time",
    "modifiedDateTime",
    "dc.dcterms.modified",
    "lastmod",
]

PUBLISH_DATE_TAGS: List[Dict[str, str]] = [
    {"attribute": "itemprop", "value": "datePublished", "content": "datetime"},
    {"attribute": "pubdate", "value": "pubdate", "content": "datetime"},
    {"attribute": "class", "value": "entry-date", "content": "datetime"},
]
ARTICLE_BODY_TAGS: List[Dict[str, Union[str, int]]] = [
    {"tag": "article", "role": "article", "score_boost": 25},
    {"itemprop": "articleBody", "score_boost": 100},
    {"itemprop": "articleText", "score_boost": 40},
    {"itemtype": "https://schema.org/Article", "score_boost": 30},
    {"itemtype": "https://schema.org/NewsArticle", "score_boost": 30},
    {"itemtype": "https://schema.org/BlogPosting", "score_boost": 20},
    {"itemtype": "https://schema.org/ScholarlyArticle", "score_boost": 20},
    {"itemtype": "https://schema.org/SocialMediaPosting", "score_boost": 20},
    {"itemtype": "https://schema.org/TechArticle", "score_boost": 20},
    {
        "class": "re:paragraph|entry-content|article-text|article-body",
        "score_boost": 15,
    },
]
META_IMAGE_TAGS: List[Dict[str, Union[str, int]]] = [
    {
        "tag": "meta",
        "attr": "property",
        "value": "og:image",
        "content": "content",
        "score": 10,
    },
    {
        "tag": "link",
        "attr": "rel",
        "value": "image_src|img_src",
        "content": "href",
        "score": 8,
    },
    {
        "tag": "meta",
        "attr": "name",
        "value": "og:image",
        "content": "content",
        "score": 8,
    },
    {"tag": "link", "attr": "rel", "value": "icon", "content": "href", "score": 5},
]
META_LANGUAGE_TAGS: List[Dict[str, str]] = [
    {"tag": "meta", "attr": "property", "value": "og:locale"},
    {"tag": "meta", "attr": "http-equiv", "value": "content-language"},
    {"tag": "meta", "attr": "name", "value": "lang"},
]

url_stopwords: List[str] = [
    "about",
    "academy",
    "account",
    "admin",
    "advert",
    "advertise",
    "adverts",
    "archive",
    "archives",
    "author",
    "authors",
    "bebo",
    "board",
    "boards",
    "browse",
    "career",
    "careers",
    "charts",
    "comment",
    "comments",
    "contact",
    "contacts",
    "coupons",
    "developer",
    "developers",
    "donate",
    "download",
    "downloads",
    "edit",
    "event",
    "events",
    "facebook",
    "faq",
    "faqs",
    "feed",
    "feeds",
    "feedback",
    "flickr",
    "forum",
    "forums",
    "friendster",
    "help",
    "how-to",
    "howto",
    "imgur",
    "info",
    "itunes",
    "jobs",
    "legal",
    "linkedin",
    "login",
    "mail",
    "map",
    "maps",
    "mobile",
    "myspace",
    "newsletter",
    "newsletters",
    "password",
    "plus",
    "preference",
    "preferences",
    "privacy",
    "privacy-policy",
    "product",
    "products",
    "profile",
    "profiles",
    "proxy",
    "purchase",
    "register",
    "search",
    "services",
    "shop",
    "shopping",
    "signup",
    "site-map",
    "siteindex",
    "sitemap",
    "sitemaps",
    "stop",
    "store",
    "stumbleupon",
    "subscribe",
    "subscription",
    "tag",
    "terms",
    "tickets",
    "toc",
    "twitter",
    "upload",
    "uploads",
    "vimeo",
    "wp-admin",
    "wp-includes",
    "wp-content",
    "wp-json",
    "wp-login",
    "xmlrpc",
    "xmlrpc.php",
    "youtube",
]

category_url_prefixes: List[str] = [
    "category",
    "categories",
    "topic",
    "topics",
    "subject",
    "subjects",
    "section",
    "sections",
    "cat",
    "cats",
]
