1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-24 12:15:40 +01:00
svtplay-dl/lib/svtplay_dl/tests/test_formatname.py

584 lines
19 KiB
Python
Raw Normal View History

from __future__ import absolute_import
2019-08-25 00:40:39 +02:00
import unittest
from svtplay_dl.service import Service
2019-08-25 00:40:39 +02:00
from svtplay_dl.utils.output import _formatname
from svtplay_dl.utils.parser import setup_defaults
class formatnameTest(unittest.TestCase):
all_combo = [
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
"test-title-service-mp4-21-0xdeadface-99-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-0xdeadface-99-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"test-title-service-mp4-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-21-0xdeadface-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-0xdeadface-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}-{episodename}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"test-title-service-mp4-0xdeadface-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-21-99-service-episodename-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-99-service-episodename-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"test-title-99-service-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-21-service-episodename-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-episodename-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{episode}-{season}-{service}-{episodename}-{id}-{ext}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"test-title-service-episodename-0xdeadface-mp4",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-99-mp4-21-episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-99-mp4-episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"0xdeadface-99-mp4-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-mp4-21-episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-mp4-episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}-{ext}-{episode}-{episodename}-{title}-{service}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"0xdeadface-mp4-episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"service-mp4-99-0xdeadface-title-episodename-21",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"service-mp4-99-0xdeadface-title-episodename",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"service-mp4-99-0xdeadface-title",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"service-mp4-0xdeadface-title-episodename-21",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"service-mp4-0xdeadface-title-episodename",
],
[
2019-08-25 00:27:31 +02:00
"{service}-{ext}-{season}-{id}-{title}-{episodename}-{episode}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"service-mp4-0xdeadface-title-episodename",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-21-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"test-title-service-mp4-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-21-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"test-title-service-mp4-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"test-{title}-{service}-{ext}-{episode}-{id}-{season}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"test-title-service-mp4-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title-mp4-21-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title-mp4-0xdeadface-99",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"title-mp4-0xdeadface-99",
],
[
"{title}-{ext}-{episode}-{id}-{season}",
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title-mp4-21-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}-{episode}-{id}-{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
"title-mp4-0xdeadface",
],
[
"{title}-{ext}-{episode}-{id}-{season}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
2019-08-25 00:27:31 +02:00
"title-mp4-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}.{episode}-{id}.{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title-mp4.21-0xdeadface.99",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}.{episode}-{id}.{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
"title-mp4-0xdeadface.99",
],
[
"{title}-{ext}.{episode}-{id}.{season}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
2019-08-25 00:27:31 +02:00
"title-mp4-0xdeadface.99",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}.{episode}-{id}.{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title-mp4.21-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"{title}-{ext}.{episode}-{id}.{season}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
"title-mp4-0xdeadface",
],
[
"{title}-{ext}.{episode}-{id}.{season}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
2019-08-25 00:27:31 +02:00
"title-mp4-0xdeadface",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-99mp4-21episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadface-99mp4episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"0xdeadface-99mp4-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadfacemp4-21episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"0xdeadfacemp4episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{id}-{season}{ext}-{episode}{episodename}-{title}-{service}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"0xdeadfacemp4episodename-title-service",
],
[
2019-08-25 00:27:31 +02:00
"{episodename}a{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
"episodenameatitle-service",
],
[
"{episodename}a{title}-{service}",
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"episodenameatitle-service",
],
[
2019-08-25 00:27:31 +02:00
"{episodename}a{title}-{service}",
2019-09-06 22:31:52 +02:00
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"atitle-service",
],
[
"{episodename}a{title}-{service}",
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"episodenameatitle-service",
],
[
2019-08-25 00:27:31 +02:00
"{episodename}a{title}-{service}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"episodenameatitle-service",
],
[
2019-08-25 00:27:31 +02:00
"{episodename}a{title}-{service}",
2019-09-06 22:31:52 +02:00
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
2019-08-25 00:27:31 +02:00
"episodenameatitle-service",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.21.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
{"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"},
"title-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.21.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
{"title": "title", "episodename": "episodename", "id": "0xdeadface"},
"title.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.s{season}e{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episode": 21,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.s99e21.episodename-0xdeadface-service.mp4",
],
[
2019-08-25 00:27:31 +02:00
"{title}.s{season}e{episode}.{episodename}-{id}-{service}.{ext}",
2019-09-06 22:31:52 +02:00
{
"title": "title",
"season": 99,
"episodename": "episodename",
"id": "0xdeadface",
"ext": "ext",
},
2019-08-25 00:27:31 +02:00
"title.s99.episodename-0xdeadface-service.mp4",
],
]
def test_formatname(self):
for item in self.all_combo:
config = setup_defaults()
config.set("filename", item[0])
service = Service(config, "localhost")
service.output.update(item[1])
2019-08-31 01:02:59 +02:00
assert _formatname(service.output, config, "mp4") == item[2]