# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

from gallery_dl.extractor import tumblr
from gallery_dl import exception


__tests__ = (
{
    "#url"     : "http://demo.tumblr.com/",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options" : {"posts": "photo"},
    "#pattern" : r"https://\d+\.media\.tumblr\.com/tumblr_[^/_]+_\d+\.jpg",
    "#count"   : 1,
},

{
    "#url"     : "http://demo.tumblr.com/",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options" : {
        "posts"   : "all",
        "external": True,
    },
    "#pattern" : r"https?://(?:$|\d+\.media\.tumblr\.com/.+\.(jpg|png|gif|mp3|mp4)|v?a\.(media\.)?tumblr\.com/tumblr_\w+)",
    "#count"   : 27,
},

{
    "#url"     : "https://mikf123-hidden.tumblr.com/",
    "#comment" : "dashboard-only",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options"  : {"access-token": None},
    "#exception": exception.AuthorizationError,
},

{
    "#url"     : "https://mikf123-hidden.tumblr.com/",
    "#comment" : "dashboard-only",
    "#class"   : tumblr.TumblrUserExtractor,
    "#count"   : 2,

    "tags": [
        "test",
        "hidden",
    ],
},

{
    "#url"     : "https://mikf123-private.tumblr.com/",
    "#comment" : "password protected",
    "#class"   : tumblr.TumblrUserExtractor,
    "#count"   : 2,

    "tags": [
        "test",
        "private",
    ],
},

{
    "#url"     : "https://mikf123-private-hidden.tumblr.com/",
    "#comment" : "dashboard-only & password protected",
    "#class"   : tumblr.TumblrUserExtractor,
    "#count"   : 2,

    "tags": [
        "test",
        "private",
        "hidden",
    ],
},

{
    "#url"     : "https://mikf123.tumblr.com/",
    "#comment" : "date-min/-max (#337)",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options" : {
        "date-min": "2018-04-01",
        "date-max": "2018-05-01",
    },
    "#count"   : 4,
},

{
    "#url"     : "https://mikf123.tumblr.com/",
    "#comment" : "date-before/-after",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options" : {
        "date-before": "2018-05-01",
        "date-after" : "2018-04-01",
    },
    "#count"   : 4,
},

{
    "#url"     : "https://tumblr.com/mikf123",
    "#comment" : "no 'www.' subdomain (#7358)",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "https://donttrustthetits.tumblr.com/",
    "#comment" : "pagination with 'date-max' (#2191) and 'api-key'",
    "#class"   : tumblr.TumblrUserExtractor,
    "#options" : {
        "access-token": None,
        "original"    : False,
        "date-max"    : "2015-04-25T00:00:00",
        "date-min"    : "2015-04-01T00:00:00",
    },
    "#count"   : 192,
},

{
    "#url"     : "https://demo.tumblr.com/page/2",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "https://demo.tumblr.com/archive",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "tumblr:http://www.b-authentique.com/",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "tumblr:www.b-authentique.com",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/view/smarties-art",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/smarties-art",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "https://www.tumblr.com/smarties-art",
    "#class"   : tumblr.TumblrUserExtractor,
},

{
    "#url"     : "http://demo.tumblr.com/post/459265350",
    "#class"   : tumblr.TumblrPostExtractor,
    "#pattern" : r"https://\d+\.media\.tumblr\.com/tumblr_[^/_]+_1280.jpg",
    "#count"   : 1,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/167770226574/text-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 2,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/181022561719/quote-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 1,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/167623351559/link-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 2,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/167633596145/video-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 2,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/167770026604/audio-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 2,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/172687798174/photo-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 4,
},

{
    "#url"     : "https://mikf123.tumblr.com/post/181022380064/chat-post",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"   : 0,
},

{
    "#url"     : "https://kichatundk.tumblr.com/post/654953419288821760",
    "#comment" : "high-quality images (#1846)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#count"       : 2,
    "#sha1_content": "d6fcc7b6f750d835d55c7f31fa3b63be26c9f89b",
},

{
    "#url"     : "https://hameru-is-cool.tumblr.com/post/639261855227002880",
    "#comment" : "high-quality images (#1344)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#exception"   : exception.NotFoundError,
    "#count"       : 2,
    "#sha1_content": "6bc19a42787e46e1bba2ef4aeef5ca28fcd3cd34",
},

{
    "#url"     : "https://k-eke.tumblr.com/post/185341184856",
    "#comment" : "wrong extension returned by api (#3095)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#options"     : {"retries": 0},
    "#results"     : "https://64.media.tumblr.com/5e9d760aba24c65beaf0e72de5aae4dd/tumblr_psj5yaqV871t1ig6no1_1280.gif",
    "#sha1_content": "3508d894b6cc25e364d182a8e1ff370d706965fb",
},

{
    "#url"     : "https://mikf123.tumblr.com/image/689860196535762944",
    "#class"   : tumblr.TumblrPostExtractor,
    "#pattern" : r"^https://\d+\.media\.tumblr\.com/134791621559a79793563b636b5fe2c6/8f1131551cef6e74-bc/s99999x99999/188cf9b8915b0d0911c6c743d152fc62e8f38491\.png$",
},

{
    "#url"     : "http://ziemniax.tumblr.com/post/109697912859/",
    "#comment" : "HTML response (#297)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#exception": exception.NotFoundError,
},

{
    "#url"     : "http://demo.tumblr.com/image/459265350",
    "#class"   : tumblr.TumblrPostExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/view/smarties-art/686047436641353728",
    "#class"   : tumblr.TumblrPostExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/smarties-art/686047436641353728",
    "#class"   : tumblr.TumblrPostExtractor,
},

{
    "#url"     : "https://www.tumblr.com/smarties-art/686047436641353728",
    "#class"   : tumblr.TumblrPostExtractor,
},

{
    "#url"     : "https://tumblr.com/smarties-art/686047436641353728",
    "#class"   : tumblr.TumblrPostExtractor,
},

{
    "#url"     : "https://www.tumblr.com/ominous-signs/809452804394663936/one-way-to-hell",
    "#comment" : "'answer'/'asks' post (#4509)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#auth"    : True,
    "#results" : "https://64.media.tumblr.com/a68cf0e9287c4557f4c0950edafb836b/5cf90cb0eb792b63-a4/s99999x99999/139223e8f778e3005e5748099f684c7816b10b14.jpg",

    "type"     : "answer",
},

{
    "#url"     : "https://www.tumblr.com/oidial/812307562622042112/i-understand-the-concern-but-you-cant-get-between",
    "#comment" : "'reblogs: same-blog' option (#9360)",
    "#class"   : tumblr.TumblrPostExtractor,
    "#auth"    : True,
    "#options" : {"reblogs": "same-blog"},
    "#results" : (
        "https://64.media.tumblr.com/4b451c7f092a6f10fe7e61d406b58725/b443af06fefd3bed-f1/s99999x99999/b7cf9ede4d0d32cf5a8dbddbb9fa33421520f91e.png",
        "https://64.media.tumblr.com/541867089dd3a5db4e2958618064b7cc/b7bda2f076509c8b-85/s99999x99999/32b899d9004f173efa63cc55fe47f096ee46b038.png",
        "https://64.media.tumblr.com/2674c9b73e96d9177cbb1c002bf83345/b7bda2f076509c8b-f7/s99999x99999/ca52c46ce449699023e87111a38798be39504c60.png",
        "https://64.media.tumblr.com/7246fec36bb3ef3be51e1d8c608a9565/b7bda2f076509c8b-0b/s99999x99999/e5f198b5e98421772f617f436feaa00bb7e062c3.png",
    ),

    "blog_name"       : "oidial",
    "date"            : "dt:2026-03-28 05:47:39",
    "id"              : 812307562622042112,
    "reblogged"       : True,
    "reblogged_from_id"   : "812300793494503424",
    "reblogged_from_name" : "oidial",
    "reblogged_from_title": "koidial but blue",
    "reblogged_from_url"  : "https://www.tumblr.com/blog/view/oidial/812300793494503424",
    "reblogged_from_uuid" : "t:7e50zZpVin78ZAzj-oLhlg",
    "blog"            : {
        "name": "oidial",
        "uuid": "t:7e50zZpVin78ZAzj-oLhlg",
    },
},

{
    "#url"     : "http://demo.tumblr.com/tagged/Times%20Square",
    "#class"   : tumblr.TumblrTagExtractor,
    "#pattern" : r"https://\d+\.media\.tumblr\.com/tumblr_[^/_]+_1280.jpg",
    "#count"   : 1,

    "search_tags": "Times Square",
},

{
    "#url"     : "https://www.tumblr.com/blog/view/smarties-art/tagged/undertale",
    "#class"   : tumblr.TumblrTagExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/smarties-art/tagged/undertale",
    "#class"   : tumblr.TumblrTagExtractor,
},

{
    "#url"     : "https://www.tumblr.com/smarties-art/tagged/undertale",
    "#class"   : tumblr.TumblrTagExtractor,
},

{
    "#url"     : "https://hirespokemon.tumblr.com/archive/tagged/ken%20sugimori",
    "#class"   : tumblr.TumblrTagExtractor,
},

{
    "#url"     : "https://mikf123.tumblr.com/day/2018/01/05",
    "#class"   : tumblr.TumblrDayExtractor,
    "#pattern" : r"https://64\.media\.tumblr\.com/1a2be8c63f1df58abd2622861696c72a/tumblr_ozm9nqst9t1wgha4yo1_1280\.jpg",
    "#count"   : 1,

    "id": 169341068404,
},

{
    "#url"     : "https://www.tumblr.com/blog/view/mikf123/day/2018/01/05",
    "#class"   : tumblr.TumblrDayExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/mikf123/day/2018/01/05",
    "#class"   : tumblr.TumblrDayExtractor,
},

{
    "#url"     : "https://www.tumblr.com/mikf123/day/2018/01/05",
    "#class"   : tumblr.TumblrDayExtractor,
},

{
    "#url"     : "http://mikf123.tumblr.com/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
    "#count"   : 1,
},

{
    "#url"     : "http://mikf123.tumblr.com/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
    "#options" : {"api-secret": None},
    "#count"   : 1,
},

{
    "#url"     : "https://www.tumblr.com/blog/view/mikf123/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
},

{
    "#url"     : "https://www.tumblr.com/blog/mikf123/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
},

{
    "#url"     : "https://www.tumblr.com/mikf123/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
},

{
    "#url"     : "https://tumblr.com/mikf123/likes",
    "#class"   : tumblr.TumblrLikesExtractor,
},

{
    "#url"     : "https://www.tumblr.com/search/nathan fielder",
    "#class"   : tumblr.TumblrSearchExtractor,
},

{
    "#url"     : "https://www.tumblr.com/search/nathan fielder/recent/quote?src=typed_query",
    "#class"   : tumblr.TumblrSearchExtractor,
},

{
    "#url"     : "https://www.tumblr.com/search/nathan%20fielder?t=90",
    "#class"   : tumblr.TumblrSearchExtractor,
},

{
    "#url"     : "https://tumblr.com/search/nathan%20fielder?t=90",
    "#class"   : tumblr.TumblrSearchExtractor,
},

{
    "#url"     : "https://www.tumblr.com/search/Sonic?src=typed_query",
    "#class"   : tumblr.TumblrSearchExtractor,
    "#options" : {"original": False},
    "#pattern" : r"https://\w+\.media\.tumblr\.com/.{10,}.\w+",
    "#range"   : "1-10",
    "count"    : range(1, 10),
},

{
    "#url"     : "https://www.tumblr.com/mikf123/following",
    "#class"   : tumblr.TumblrFollowingExtractor,
    "#results" : (
        "https://smarties-art.tumblr.com/",
        "https://demo.tumblr.com/",
    ),

    "can_show_badges": bool,
    "description"    : str,
    "name"           : str,
    "title"          : str,
    "tumblrmart_accessories": {},
    "updated"        : int,
    "url"            : str,
    "uuid"           : str,
},

{
    "#url"      : "https://www.tumblr.com/mikf123/followers",
    "#class"    : tumblr.TumblrFollowersExtractor,
    "#exception": exception.AuthorizationError,
},

)
