bugfixes for info.json + its support for ORF TVthek

This commit is contained in:
Karl Voit 2019-10-19 15:27:36 +02:00
parent 21a505eee3
commit 2525a0dbf2
3 changed files with 418 additions and 10 deletions

View file

@ -83,7 +83,7 @@ When downloading TV shows using [[https://github.com/mediathekview/MediathekView
- ffmpeg > Zieldateiname > =%DT%d %s - %t - %T -ORIGINALhd- %N.mp4=
- ffmpeg > Schalter > =-user_agent "Mozilla" -i %f -c copy -bsf:a aac_adtstoasc **=
When applying =guess-filename= on the resulting files, you will get something like this:
When applying =guessfilename= on the resulting files, you will get something like this:
#+BEGIN_EXAMPLE
20180509T235000 ORF - ZIB 24 - Auswirkungen nach US-Aus für Atomdeal -ORIGINAL- 2018-05-09_2350_tl_01_ZIB-24_Auswirkungen-na__13976363__o__1735069995__s14297628_8__BCK1HD_23514710P_23540405P_Q4A.mp4 ...
@ -112,6 +112,52 @@ Please note that this does not work with a show whose chunks do cross
midnight since the date is always taken from the start of the show and
the time from the actual time being shown.
** .info.json Meta-Data Files
:PROPERTIES:
:CREATED: [2019-10-19 Sat 15:21]
:END:
If you do download a media file and its associated separate
=.info.json= file (both base-names without file extension need to
match), this tool is able to parse the meta-data to derive a new file
name.
Currently, there are two meta-data formats supported: ORG TVthek and
YouTube, both via http://rg3.github.io/youtube-dl/
: youtube-dl --write-info-json <URL>
This results, for example, with files like these:
#+BEGIN_VERSE
Durchbruch bei Brexit-Verhandlungen-14577219.info.json
Durchbruch bei Brexit-Verhandlungen-14577219.mp4
Isolierte Familie - 58-jähriger Österreicher in U-Haft-14577221.info.json
Isolierte Familie - 58-jähriger Österreicher in U-Haft-14577221.mp4
The Star7 PDA Prototype-Ahg8OBYixL0.info.json
The Star7 PDA Prototype-Ahg8OBYixL0.mp4
#+END_VERSE
Please notice the associated =mp4= files as well as the =info.json=
files.
Applying guess-filename on these files look like this:
#+BEGIN_EXAMPLE
vk@sherri ~tmp % guessfilename *mp4
Durchbruch bei Brexit-Verhandlungen-14577219.mp4 ...
→ 2019-10-17T16.59.07 ORF - ZIB 17 00 - Durchbruch bei Brexit-Verhandlungen -- highquality.mp4
Isolierte Familie - 58-jähriger Österreicher in U-Haft-14577221.mp4 ...
→ 2019-10-17T17.01.44 ORF - ZIB 17 00 - Isolierte Familie: 58-jähriger Österreicher in U-Haft -- highquality.mp4
The Star7 PDA Prototype-Ahg8OBYixL0.mp4 ...
→ 2007-09-13 youtube - The Star7 PDA Prototype - Ahg8OBYixL0.mp4
#+END_EXAMPLE
The =info.json= files are not removed or renamed.
* Related tools and workflows
This tool is part of a tool-set which I use to manage my digital files

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
PROG_VERSION = u"Time-stamp: <2019-10-19 14:06:23 vk>"
PROG_VERSION = u"Time-stamp: <2019-10-19 15:20:22 vk>"
# TODO:
@ -440,8 +440,6 @@ class GuessFilename(object):
# but with varying quality indicator: Q4A (low), Q6A (high), Q8C (HD)
film_regex_match = re.match(self.FILM_URL_REGEX, film_url)
#import pdb; pdb.set_trace()
if not film_regex_match:
print()
logging.warn(self.FILM_URL_REGEX_MISMATCH_HELP_TEXT)
@ -842,17 +840,57 @@ class GuessFilename(object):
data = json.load(json_data)
if "upload_date" in data.keys() and \
len(data['upload_date']) == 8 and \
"extractor" in data.keys() and \
"display_id" in data.keys() and \
"ext" in data.keys() and \
"fulltitle" in data.keys():
logging.debug('derive_new_filename_from_json_metadata: found all required meta data for YouTube download file style')
if data['upload_date'] and len(data['upload_date']) == 8 and \
data["extractor_key"] and data["extractor_key"] == "Youtube":
logging.debug('derive_new_filename_from_json_metadata: found all ' +
'required meta data for YouTube download file style')
# example from unit tests: "2007-09-13 youtube - The Star7 PDA Prototype - Ahg8OBYixL0.mp4"
return data['upload_date'][:4] + '-' + data['upload_date'][4:6] + '-' + data['upload_date'][6:] + ' ' + data["extractor"] + ' - ' + data["fulltitle"] + ' - ' + data["display_id"] + '.' + data["ext"]
else:
logging.debug('derive_new_filename_from_json_metadata: found all required meta data ' +
'for YouTube download file style but upload_date or extractor_key do ' +
'not match expected format')
if "extractor_key" in data.keys() and \
"fulltitle" in data.keys() and \
"url" in data.keys() and \
"ext" in data.keys():
if data["extractor_key"] == "ORFTVthek":
logging.debug('derive_new_filename_from_json_metadata: found all ' +
'required meta data for ORF TVthek download file style')
# example from unit tests: "2019-10-17T16.59.07 ORF - ZIB 17 00 - Durchbruch bei Brexit-Verhandlungen -- highquality.mp4"
# data['url'] == 'https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/chunklist.m3u8'
# data['url'].split('/') == ['https:', '', 'apasfiis.sf.apa.at', 'cms-worldwide_nas', '_definst_', 'nas', 'cms-worldwide', 'online', '2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4', 'chunklist.m3u8']
# data['url'].split('/')[-2:-1][0] == '2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4'
# match.groups() == ('2019', '10', '17', '17', '00', None, None, 'ZIB-17-00_Durchbruch-bei-_', '16', '59', '07', '07', '17', '00', '03', '03', 'Q8C')
# JSON:
# "extractor_key": "ORFTVthek",
# "fulltitle": "Durchbruch bei Brexit-Verhandlungen",
# "url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/
# 2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/chunklist.m3u8",
# "ext": "mp4",
match = re.match(self.MEDIATHEKVIEW_RAW_REGEX_STRING, data['url'].split('/')[-2:-1][0])
qualityindicator = self.translate_ORF_quality_string_to_tag(match.group(17)) # e.g., 'Q8C'
return self.build_string_via_indexgroups(match, [1, '-', 2, '-', 3, 'T', 9, '.', 10, '.', 11, ' ORF - ']) + \
match.group(8).split('_')[0].replace('-', ' ') + ' - ' + data['fulltitle'] + ' -- ' + qualityindicator + '.' + data['ext']
else:
logging.debug('derive_new_filename_from_json_metadata: do not understand this type of JSON meta data')
logging.debug('derive_new_filename_from_json_metadata: found all required meta data ' +
'for ORF TVthek download file style but extractor_key does ' +
'not match expected format')
else:
logging.debug('derive_new_filename_from_json_metadata: do not ' +
'understand this type of JSON meta data')
return False
json_data.close()

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python; -*-
# Time-stamp: <2019-10-19 14:10:23 vk>
# Time-stamp: <2019-10-19 15:20:13 vk>
import unittest
import logging
@ -466,6 +466,330 @@ class TestGuessFilename(unittest.TestCase):
os.remove(jsonfile)
os.rmdir(tmpdir)
def test_orf_tvthek_json_metadata(self):
tmpdir=tempfile.mkdtemp()
mediafile=tempfile.mkstemp(dir=tmpdir, prefix='Durchbruch bei Brexit-Verhandlungen-', suffix='.mp4')[1]
jsonfile=os.path.join(os.path.dirname(mediafile), os.path.splitext(mediafile)[0] + '.info.json')
with open(mediafile, 'w') as outputhandle:
outputhandle.write('This is not of any interest. Delete me.')
with open(jsonfile, 'w') as outputhandle:
outputhandle.write("""{
"duration": null,
"playlist_title": null,
"playlist": "14577219",
"width": 1280,
"extractor_key": "ORFTVthek",
"thumbnail": null,
"playlist_uploader": null,
"description": "Es ist vollbracht: Die EU und Großbritannien haben sich auf einen Brexit-Vertrag geeinigt. Das bestätigten Kommissionspräsident Juncker und Premier Johnson. Durch ist die Einigung damit aber noch längst nicht.",
"extractor": "orf:tvthek",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/chunklist.m3u8",
"playlist_id": "14577219",
"height": 720,
"n_entries": 8,
"format_id": "hls-Q8C-Sehr_hoch-3886",
"_type": "video",
"display_id": "14577219",
"vcodec": "avc1.77.31",
"tbr": 3886.742,
"upload_date": null,
"fps": null,
"subtitles": {
"de-AT": [
{
"url": "https://api-tvthek.orf.at/uploads/media/subtitles/0091/63/8b058fcdeb1046abe4866a70d6a7280c06b2ee3a.",
"ext": "unknown_video"
},
{
"url": "https://api-tvthek.orf.at/uploads/media/subtitles/0091/63/505af4543d7f9e5d3ab53ac37621d1a1e9e4cad7.srt",
"ext": "srt"
},
{
"url": "https://api-tvthek.orf.at/uploads/media/subtitles/0091/63/abee3589f30be631cad01b8ae93def8a2d76f7dd.vtt",
"ext": "vtt"
},
{
"url": "https://api-tvthek.orf.at/uploads/media/subtitles/0091/63/6a5b96f23da49f3d4da1905b2d1477b6282da83d.smi",
"ext": "smi"
},
{
"url": "https://api-tvthek.orf.at/uploads/media/subtitles/0091/63/1207bb113fabd7865efa04f0870bd0de614c8a4c.ttml",
"ext": "ttml"
}
]
},
"id": "14577219",
"formats": [
{
"protocol": "f4m",
"width": 320,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"manifest_url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q1A.3gp/manifest.f4m",
"url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q1A.3gp/manifest.f4m",
"height": 180,
"ext": "flv",
"format_id": "hds-Q1A-Niedrig-430",
"tbr": 430,
"vcodec": null,
"format": "hds-Q1A-Niedrig-430 - 320x180"
},
{
"fps": null,
"protocol": "m3u8",
"width": 320,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"acodec": "mp4a.40.2",
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q1A.3gp/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q1A.3gp/chunklist.m3u8",
"height": 180,
"ext": "mp4",
"format_id": "hls-Q1A-Niedrig-516",
"tbr": 516.024,
"vcodec": "avc1.77.30",
"format": "hls-Q1A-Niedrig-516 - 320x180"
},
{
"protocol": "f4m",
"width": 640,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"manifest_url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q4A.mp4/manifest.f4m",
"url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q4A.mp4/manifest.f4m",
"height": 360,
"ext": "flv",
"format_id": "hds-Q4A-Mittel-989",
"tbr": 989,
"vcodec": null,
"format": "hds-Q4A-Mittel-989 - 640x360"
},
{
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/chunklist_b992000.m3u8",
"protocol": "m3u8",
"ext": "mp4",
"fps": null,
"format_id": "hls-QXB-Adaptiv-992",
"tbr": 992.0,
"preference": null,
"format": "hls-QXB-Adaptiv-992 - unknown",
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
},
{
"fps": null,
"protocol": "m3u8",
"width": 640,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"acodec": "mp4a.40.2",
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q4A.mp4/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q4A.mp4/chunklist.m3u8",
"height": 360,
"ext": "mp4",
"format_id": "hls-Q4A-Mittel-1236",
"tbr": 1236.117,
"vcodec": "avc1.77.30",
"format": "hls-Q4A-Mittel-1236 - 640x360"
},
{
"protocol": "f4m",
"width": 960,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"manifest_url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q6A.mp4/manifest.f4m",
"url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q6A.mp4/manifest.f4m",
"height": 540,
"ext": "flv",
"format_id": "hds-Q6A-Hoch-1991",
"tbr": 1991,
"vcodec": null,
"format": "hds-Q6A-Hoch-1991 - 960x540"
},
{
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/chunklist_b1992000.m3u8",
"protocol": "m3u8",
"ext": "mp4",
"fps": null,
"format_id": "hls-QXB-Adaptiv-1992",
"tbr": 1992.0,
"preference": null,
"format": "hls-QXB-Adaptiv-1992 - unknown",
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
},
{
"fps": null,
"protocol": "m3u8",
"width": 960,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"acodec": "mp4a.40.2",
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q6A.mp4/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q6A.mp4/chunklist.m3u8",
"height": 540,
"ext": "mp4",
"format_id": "hls-Q6A-Hoch-2437",
"tbr": 2437.8,
"vcodec": "avc1.77.31",
"format": "hls-Q6A-Hoch-2437 - 960x540"
},
{
"protocol": "f4m",
"width": 1280,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"manifest_url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/manifest.f4m",
"url": "https://apasfiis.sf.apa.at/f4m/cms-worldwide/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/manifest.f4m",
"height": 720,
"ext": "flv",
"format_id": "hds-Q8C-Sehr_hoch-3188",
"tbr": 3188,
"vcodec": null,
"format": "hds-Q8C-Sehr_hoch-3188 - 1280x720"
},
{
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_hr.smil/chunklist_b3192000.m3u8",
"protocol": "m3u8",
"ext": "mp4",
"fps": null,
"format_id": "hls-QXB-Adaptiv-3192",
"tbr": 3192.0,
"preference": null,
"format": "hls-QXB-Adaptiv-3192 - unknown",
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
}
},
{
"fps": null,
"protocol": "m3u8",
"width": 1280,
"preference": null,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"acodec": "mp4a.40.2",
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/playlist.m3u8",
"url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/chunklist.m3u8",
"height": 720,
"ext": "mp4",
"format_id": "hls-Q8C-Sehr_hoch-3886",
"tbr": 3886.742,
"vcodec": "avc1.77.31",
"format": "hls-Q8C-Sehr_hoch-3886 - 1280x720"
}
],
"protocol": "m3u8",
"manifest_url": "https://apasfiis.sf.apa.at/cms-worldwide_nas/_definst_/nas/cms-worldwide/online/2019-10-17_1700_tl_02_ZIB-17-00_Durchbruch-bei-__14029194__o__9751208575__s14577219_9__ORF2BHD_16590721P_17000309P_Q8C.mp4/playlist.m3u8",
"fulltitle": "Durchbruch bei Brexit-Verhandlungen",
"preference": null,
"webpage_url_basename": "14577219",
"acodec": "mp4a.40.2",
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3554.1 Safari/537.36",
"Accept-Language": "en-us,en;q=0.5",
"Cookie": "ASP.NET_SessionId=0npxlhiy2jqaapscvafzp0sf",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
},
"title": "Durchbruch bei Brexit-Verhandlungen",
"_filename": "Durchbruch bei Brexit-Verhandlungen-14577219.mp4",
"webpage_url": "https://tvthek.orf.at/profile/ZIB-1700/71284/ZIB-1700/14029194/Durchbruch-bei-Brexit-Verhandlungen/14577219",
"ext": "mp4",
"playlist_uploader_id": null,
"format": "hls-Q8C-Sehr_hoch-3886 - 1280x720",
"playlist_index": 2
}""")
new_mediafilename_generated = os.path.join(tmpdir, self.guess_filename.handle_file(mediafile, False))
new_mediafilename_comparison = os.path.join(tmpdir, "2019-10-17T16.59.07 ORF - ZIB 17 00 - Durchbruch bei Brexit-Verhandlungen -- highquality.mp4")
self.assertEqual(new_mediafilename_generated, new_mediafilename_comparison)
os.remove(new_mediafilename_generated)
os.remove(jsonfile)
os.rmdir(tmpdir)
def test_adding_tags(self):
self.assertEqual(self.guess_filename.adding_tags(['foo'], ['bar']), ['foo', 'bar'])