add tests for specific datetime values

This commit is contained in:
Mike Fährmann
2020-02-23 16:48:30 +01:00
parent 80ecb99089
commit 4e361b3008
18 changed files with 45 additions and 40 deletions

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -40,7 +40,7 @@ class _8musesAlbumExtractor(Extractor):
"parent" : 10454, "parent" : 10454,
"views" : int, "views" : int,
"likes" : int, "likes" : int,
"date" : "type:datetime", "date" : "dt:2018-07-10 00:00:00",
}, },
}, },
}), }),

View File

@@ -111,7 +111,7 @@ class BcyPostExtractor(BcyExtractor):
"post": { "post": {
"id" : 6355835481002893070, "id" : 6355835481002893070,
"tags" : list, "tags" : list,
"date" : "type:datetime", "date" : "dt:2016-11-22 08:47:46",
"parody" : "东方PROJECT", "parody" : "东方PROJECT",
"content": "re:根据微博的建议稍微做了点修改", "content": "re:根据微博的建议稍微做了点修改",
"likes" : int, "likes" : int,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -99,7 +99,7 @@ class BloggerPostExtractor(BloggerExtractor):
"pattern": r"https://3.bp.blogspot.com/.*/s0/Icy-Moonrise-.*.jpg", "pattern": r"https://3.bp.blogspot.com/.*/s0/Icy-Moonrise-.*.jpg",
"keyword": { "keyword": {
"blog": { "blog": {
"date" : "type:datetime", "date" : "dt:2010-11-21 18:19:42",
"description": "", "description": "",
"id" : "5623928067739466034", "id" : "5623928067739466034",
"kind" : "blogger#blog", "kind" : "blogger#blog",
@@ -114,7 +114,7 @@ class BloggerPostExtractor(BloggerExtractor):
"post": { "post": {
"author" : "Julian Bunker", "author" : "Julian Bunker",
"content" : str, "content" : str,
"date" : "type:datetime", "date" : "dt:2010-12-26 01:08:00",
"etag" : str, "etag" : str,
"id" : "6955139236418998998", "id" : "6955139236418998998",
"kind" : "blogger#post", "kind" : "blogger#post",

View File

@@ -153,7 +153,7 @@ class FuraffinityPostExtractor(FuraffinityExtractor):
"url": "eae4ef93d99365c69b31a37561bd800c03d336ad", "url": "eae4ef93d99365c69b31a37561bd800c03d336ad",
"keyword": { "keyword": {
"artist" : "mirlinthloth", "artist" : "mirlinthloth",
"date" : "type:datetime", "date" : "dt:2016-11-27 17:24:06",
"description": "A Song made playing the game Cosmic DJ.", "description": "A Song made playing the game Cosmic DJ.",
"extension" : "mp3", "extension" : "mp3",
"filename" : r"re:\d+\.\w+_dj_fennmink_-_bude_s_4_ever", "filename" : r"re:\d+\.\w+_dj_fennmink_-_bude_s_4_ever",

View File

@@ -247,7 +247,7 @@ class HentaifoundryImageExtractor(HentaifoundryExtractor):
"content": "91bf01497c39254b6dfb234a18e8f01629c77fd1", "content": "91bf01497c39254b6dfb234a18e8f01629c77fd1",
"keyword": { "keyword": {
"artist" : "Tenpura", "artist" : "Tenpura",
"date" : "type:datetime", "date" : "dt:2016-02-22 14:41:19",
"description": "Thank you!", "description": "Thank you!",
"height" : 700, "height" : 700,
"index" : 407501, "index" : 407501,

View File

@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2015-2019 Mike Fährmann # Copyright 2015-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extract images from https://imgur.com/""" """Extractors for https://imgur.com/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, exception from .. import text, exception
@@ -65,7 +65,7 @@ class ImgurImageExtractor(ImgurExtractor):
"account_url" : None, "account_url" : None,
"animated" : False, "animated" : False,
"bandwidth" : int, "bandwidth" : int,
"date" : "type:datetime", "date" : "dt:2016-11-10 14:24:35",
"datetime" : 1478787875, "datetime" : 1478787875,
"description" : None, "description" : None,
"edited" : "0", "edited" : "0",
@@ -142,7 +142,7 @@ class ImgurAlbumExtractor(ImgurExtractor):
"cover_edited": None, "cover_edited": None,
"cover_height": 1400, "cover_height": 1400,
"cover_width" : 951, "cover_width" : 951,
"date" : "type:datetime", "date" : "dt:2015-10-09 10:37:50",
"datetime" : 1444387070, "datetime" : 1444387070,
"description" : None, "description" : None,
"favorite" : False, "favorite" : False,

View File

@@ -1,12 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018-2019 Leonardo Taccari, Mike Fährmann # Copyright 2018-2019 Leonardo Taccari
# Copyright 2018-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extract images from https://www.instagram.com/""" """Extractors for https://www.instagram.com/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text, exception from .. import text, exception
@@ -306,7 +307,7 @@ class InstagramImageExtractor(InstagramExtractor):
r"/v(p/[0-9a-f]+/[0-9A-F]+)?/t51.2885-15/e35" r"/v(p/[0-9a-f]+/[0-9A-F]+)?/t51.2885-15/e35"
r"/44877605_725955034447492_3123079845831750529_n.jpg", r"/44877605_725955034447492_3123079845831750529_n.jpg",
"keyword": { "keyword": {
"date": "type:datetime", "date": "dt:2018-11-29 01:04:04",
"description": str, "description": str,
"height": int, "height": int,
"likes": int, "likes": int,
@@ -333,7 +334,7 @@ class InstagramImageExtractor(InstagramExtractor):
("https://www.instagram.com/p/Bqxp0VSBgJg/", { ("https://www.instagram.com/p/Bqxp0VSBgJg/", {
"pattern": r"/47129943_191645575115739_8539303288426725376_n\.mp4", "pattern": r"/47129943_191645575115739_8539303288426725376_n\.mp4",
"keyword": { "keyword": {
"date": "type:datetime", "date": "dt:2018-11-29 19:23:58",
"description": str, "description": str,
"height": int, "height": int,
"likes": int, "likes": int,
@@ -349,7 +350,7 @@ class InstagramImageExtractor(InstagramExtractor):
("https://www.instagram.com/tv/BkQjCfsBIzi/", { ("https://www.instagram.com/tv/BkQjCfsBIzi/", {
"pattern": r"/10000000_1760663964018792_716207142595461120_n\.mp4", "pattern": r"/10000000_1760663964018792_716207142595461120_n\.mp4",
"keyword": { "keyword": {
"date": "type:datetime", "date": "dt:2018-06-20 19:51:32",
"description": str, "description": str,
"height": int, "height": int,
"likes": int, "likes": int,

View File

@@ -35,7 +35,7 @@ class IssuuPublicationExtractor(IssuuBase, GalleryExtractor):
"access" : "public", "access" : "public",
"articleStories": list, "articleStories": list,
"contentRating" : dict, "contentRating" : dict,
"date" : "type:datetime", "date" : "dt:2019-09-16 00:00:00",
"description" : "re:Motions, the brand new publication by I", "description" : "re:Motions, the brand new publication by I",
"documentId" : r"re:\d+-d99ec95935f15091b040cb8060f05510", "documentId" : r"re:\d+-d99ec95935f15091b040cb8060f05510",
"documentName" : "motions-1-2019", "documentName" : "motions-1-2019",

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2016-2019 Mike Fährmann # Copyright 2016-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -59,7 +59,7 @@ class LusciousAlbumExtractor(LusciousExtractor):
"cover" : "re:https://\\w+.luscious.net/.+/277031/", "cover" : "re:https://\\w+.luscious.net/.+/277031/",
"created" : 1479625853, "created" : 1479625853,
"created_by" : "NTRshouldbeillegal", "created_by" : "NTRshouldbeillegal",
"date" : "type:datetime", "date" : "dt:2016-11-20 07:10:53",
"description" : "Enjoy.", "description" : "Enjoy.",
"download_url": "/download/824778/277031/", "download_url": "/download/824778/277031/",
"genres" : list, "genres" : list,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018-2019 Mike Fährmann # Copyright 2018-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -194,7 +194,7 @@ class NewgroundsImageExtractor(NewgroundsExtractor):
"keyword": { "keyword": {
"artist" : ["tomfulp"], "artist" : ["tomfulp"],
"comment" : "re:Consider this the bottom threshold for ", "comment" : "re:Consider this the bottom threshold for ",
"date" : "type:datetime", "date" : "dt:2009-06-04 14:44:05",
"description": "re:Consider this the bottom threshold for ", "description": "re:Consider this the bottom threshold for ",
"favorites" : int, "favorites" : int,
"filename" : "94_tomfulp_ryu-is-hawt", "filename" : "94_tomfulp_ryu-is-hawt",
@@ -241,7 +241,7 @@ class NewgroundsMediaExtractor(NewgroundsExtractor):
"keyword": { "keyword": {
"artist" : ["psychogoldfish", "tomfulp"], "artist" : ["psychogoldfish", "tomfulp"],
"comment" : "re:People have been asking me how I like the ", "comment" : "re:People have been asking me how I like the ",
"date" : "type:datetime", "date" : "dt:2012-02-08 21:40:56",
"description": "re:People have been asking how I like the ", "description": "re:People have been asking how I like the ",
"favorites" : int, "favorites" : int,
"filename" : "527818_alternate_1896", "filename" : "527818_alternate_1896",
@@ -259,7 +259,7 @@ class NewgroundsMediaExtractor(NewgroundsExtractor):
"keyword": { "keyword": {
"artist" : ["zj", "tomfulp"], "artist" : ["zj", "tomfulp"],
"comment" : "re:RECORDED 12-09-2014\n\nFrom The ZJ \"Late ", "comment" : "re:RECORDED 12-09-2014\n\nFrom The ZJ \"Late ",
"date" : "type:datetime", "date" : "dt:2015-02-23 19:31:59",
"description": "From The ZJ Report Show!", "description": "From The ZJ Report Show!",
"favorites" : int, "favorites" : int,
"index" : 609768, "index" : 609768,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -86,7 +86,7 @@ class NozomiPostExtractor(NozomiExtractor):
"character": ["patchouli knowledge"], "character": ["patchouli knowledge"],
"copyright": ["touhou"], "copyright": ["touhou"],
"dataid" : "re:aaa9f7c632cde1e1a5baaff3fb6a6d857ec73df7fdc5cf5a", "dataid" : "re:aaa9f7c632cde1e1a5baaff3fb6a6d857ec73df7fdc5cf5a",
"date" : "type:datetime", "date" : "dt:2016-07-26 02:32:03",
"extension": "jpg", "extension": "jpg",
"favorites": int, "favorites": int,
"filename" : str, "filename" : str,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -21,8 +21,8 @@ class PururinGalleryExtractor(GalleryExtractor):
("https://pururin.io/gallery/38661/iowant-2", { ("https://pururin.io/gallery/38661/iowant-2", {
"pattern": r"https://cdn.pururin.io/\w+/images/data/\d+/\d+\.jpg", "pattern": r"https://cdn.pururin.io/\w+/images/data/\d+/\d+\.jpg",
"keyword": { "keyword": {
"title" : "Iowant 2!!", "title" : "re:I ?owant 2!!",
"title_en" : "Iowant 2!!", "title_en" : "re:I ?owant 2!!",
"title_jp" : "", "title_jp" : "",
"gallery_id": 38661, "gallery_id": 38661,
"count" : 19, "count" : 19,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -106,7 +106,7 @@ class SexcomPinExtractor(SexcomExtractor):
"content": "e579e3283fea812d0545a3f79734b79bc3c51acb", "content": "e579e3283fea812d0545a3f79734b79bc3c51acb",
"keyword": { "keyword": {
"comments" : int, "comments" : int,
"date" : "type:datetime", "date" : "dt:2018-10-02 21:18:17",
"extension": "jpg", "extension": "jpg",
"filename" : "20037816", "filename" : "20037816",
"likes" : int, "likes" : int,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -52,7 +52,7 @@ class TsuminoGalleryExtractor(TsuminoBase, GalleryExtractor):
"title_en" : r"re:Shikoshiko Daisuki Nightingale \+ Kaijou", "title_en" : r"re:Shikoshiko Daisuki Nightingale \+ Kaijou",
"title_jp" : "シコシコ大好きナイチンゲール + 会場限定おまけ本", "title_jp" : "シコシコ大好きナイチンゲール + 会場限定おまけ本",
"gallery_id": 40996, "gallery_id": 40996,
"date" : "type:datetime", "date" : "dt:2018-06-29 00:00:00",
"count" : 42, "count" : 42,
"collection": "", "collection": "",
"artist" : ["Itou Life"], "artist" : ["Itou Life"],

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -192,7 +192,7 @@ class VscoImageExtractor(VscoExtractor):
"grid" : "erenyildiz", "grid" : "erenyildiz",
"meta" : dict, "meta" : dict,
"tags" : list, "tags" : list,
"date" : "type:datetime", "date" : "dt:2019-07-21 19:12:11",
"video" : False, "video" : False,
"width" : 1537, "width" : 1537,
"height": 1537, "height": 1537,

View File

@@ -1,12 +1,12 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2018-2019 Mike Fährmann # Copyright 2018-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation. # published by the Free Software Foundation.
"""Extract images from https://wallhaven.cc/""" """Extractors for https://wallhaven.cc/"""
from .common import Extractor, Message from .common import Extractor, Message
from .. import text from .. import text
@@ -77,7 +77,7 @@ class WallhavenImageExtractor(WallhavenExtractor):
"group" : "Owner/Developer", "group" : "Owner/Developer",
"username" : "AksumkA", "username" : "AksumkA",
}, },
"date" : "type:datetime", "date" : "dt:2014-08-31 06:17:19",
"wh_category": "anime", "wh_category": "anime",
"views" : int, "views" : int,
"favorites" : int, "favorites" : int,

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright 2019 Mike Fährmann # Copyright 2019-2020 Mike Fährmann
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License version 2 as
@@ -49,7 +49,7 @@ class XhamsterGalleryExtractor(XhamsterExtractor):
"pageURL": str, "pageURL": str,
"thumbURL": str, "thumbURL": str,
"gallery": { "gallery": {
"date": "type:datetime", "date": "dt:2019-04-16 00:07:31",
"description": "", "description": "",
"dislikes": int, "dislikes": int,
"id": 11748968, "id": 11748968,

View File

@@ -12,6 +12,7 @@ import sys
import re import re
import json import json
import hashlib import hashlib
import datetime
import unittest import unittest
from gallery_dl import extractor, util, job, config, exception from gallery_dl import extractor, util, job, config, exception
@@ -154,6 +155,9 @@ class TestExtractorResults(unittest.TestCase):
elif isinstance(test, str): elif isinstance(test, str):
if test.startswith("re:"): if test.startswith("re:"):
self.assertRegex(value, test[3:], msg=key) self.assertRegex(value, test[3:], msg=key)
elif test.startswith("dt:"):
self.assertIsInstance(value, datetime.datetime, msg=key)
self.assertEqual(str(value), test[3:], msg=key)
elif test.startswith("type:"): elif test.startswith("type:"):
self.assertEqual(type(value).__name__, test[5:], msg=key) self.assertEqual(type(value).__name__, test[5:], msg=key)
else: else: