-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathguessfilename_test.py
executable file
·1247 lines (1148 loc) · 81.1 KB
/
guessfilename_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python; -*-
# Time-stamp: <2023-03-15 10:52:15 vk>
# This script checks the functionality provided by guessfilename.
# Its execution depends on pytest (see https://docs.pytest.org/en/
# for additional details). Depending on your local installation,
# the tests are launched by either command `pytest`, or `pytest-3`.
import unittest
import logging
import tempfile
import os
import os.path
import sys
import re
from guessfilename import GuessFilename
from guessfilename import FileSizePlausibilityException
class TestGuessFilename(unittest.TestCase):
guess_filename = None
def handle_logging(self, verbose=False, quiet=False):
"""Log handling and configuration"""
if verbose:
FORMAT = "%(levelname)-8s %(asctime)-15s %(message)s"
logging.basicConfig(level=logging.DEBUG, format=FORMAT)
elif quiet:
FORMAT = "%(levelname)-8s %(message)s"
logging.basicConfig(level=logging.ERROR, format=FORMAT)
else:
FORMAT = "%(levelname)-8s %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)
def setUp(self):
verbose = True
quiet = False
CONFIGDIR = os.path.join(os.path.expanduser("~"), ".config/guessfilename")
sys.path.insert(0, CONFIGDIR) # add CONFIGDIR to Python path in order to find config file
try:
import guessfilenameconfig
except ImportError:
print("Could not find \"guessfilenameconfig.py\" in directory \"" + CONFIGDIR + "\".\nPlease take a look at \"guessfilenameconfig-TEMPLATE.py\", copy it, and configure accordingly.")
sys.exit(1)
self.handle_logging(verbose, quiet)
self.guess_filename = GuessFilename(guessfilenameconfig, logging)
def tearDown(self):
pass
def test_rename_file(self):
tmp_oldfile1 = tempfile.mkstemp()[1]
oldbasename = os.path.basename(tmp_oldfile1)
dirname = os.path.abspath(os.path.dirname(tmp_oldfile1))
newbasename = 'test_rename_file'
newfilename = os.path.join(dirname, newbasename)
self.assertTrue(os.path.isfile(tmp_oldfile1))
self.assertFalse(os.path.isfile(newfilename))
# return False if files are identical
self.assertFalse(self.guess_filename.rename_file(dirname, oldbasename, oldbasename, dryrun=True, quiet=True))
# return False if original file does not exist
self.assertFalse(self.guess_filename.rename_file(dirname, "test_rename_file_this-is-a-non-existing-file", oldbasename, dryrun=True, quiet=True))
# return False if target filename does exist
tmp_oldfile2 = tempfile.mkstemp()[1]
self.assertTrue(os.path.isfile(tmp_oldfile2))
oldbasename2 = os.path.basename(tmp_oldfile2)
self.assertFalse(self.guess_filename.rename_file(dirname, oldbasename, oldbasename2, dryrun=True, quiet=True))
os.remove(tmp_oldfile2)
# no change with dryrun set:
self.assertTrue(self.guess_filename.rename_file(dirname, oldbasename, newbasename, dryrun=True, quiet=True))
self.assertTrue(os.path.isfile(tmp_oldfile1))
self.assertFalse(os.path.isfile(newfilename))
# do rename:
self.assertTrue(self.guess_filename.rename_file(dirname, oldbasename, newbasename, dryrun=False, quiet=True))
self.assertFalse(os.path.isfile(tmp_oldfile1))
self.assertTrue(os.path.isfile(newfilename))
os.remove(newfilename)
def test_youtube_json_metadata(self):
tmpdir=tempfile.mkdtemp()
mediafile=tempfile.mkstemp(dir=tmpdir, prefix='The Star7 PDA Prototype-', 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("""{
"upload_date": "20070913",
"playlist": null,
"age_limit": 0,
"http_headers": {
"Accept-Language": "en-us,en;q=0.5",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding": "gzip, deflate",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7"
},
"format_id": "18",
"automatic_captions": null,
"duration": 591,
"subtitles": null,
"tags": [
"java",
"oak",
"star7",
"*7",
"green",
"project",
"sun",
"james",
"gosling",
"duke"
],
"uploader_url": "http://www.youtube.com/user/enaiel",
"average_rating": 4.9502072,
"categories": [
"Howto & Style"
],
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=18&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fmp4&gir=yes&clen=26294671&ratebypass=yes&dur=591.458&lmt=1415795880482368&mt=1571330440&fvip=5&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRAIgY-EEHBbMKgL3IOtT574RJJNPZRQgYw3gZb682o8-TfQCIEwAsWs8FjYXX8mBZR_wRZlgz1XcGlfN1LCoVbYmhNu_&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D",
"thumbnail": "https://i.ytimg.com/vi/Ahg8OBYixL0/hqdefault.jpg",
"extractor": "youtube",
"season_number": null,
"track": null,
"height": 262,
"series": null,
"uploader": "Enaiel",
"like_count": 238,
"artist": null,
"protocol": "https",
"playlist_index": null,
"release_date": null,
"end_time": null,
"formats": [
{
"height": null,
"filesize": 3121140,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "249",
"vcodec": "none",
"protocol": "https",
"ext": "webm",
"downloader_options": {
"http_chunk_size": 10485760
},
"acodec": "opus",
"format": "249 - audio only (tiny)",
"format_note": "tiny",
"tbr": 64.949,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=249&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=audio%2Fwebm&gir=yes&clen=3121140&dur=591.401&lmt=1507622941749296&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRAIgMEEY1cSicYKiXxBGisCl6HTs8BqyAM7BADcrxSbs8GECIEDuTMg-dFUTZmXxV-wtIO4yrVNBGO2rwvJGg-g0cEP6&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"abr": 50,
"asr": 48000,
"width": null
},
{
"height": null,
"filesize": 3854861,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "250",
"vcodec": "none",
"protocol": "https",
"ext": "webm",
"downloader_options": {
"http_chunk_size": 10485760
},
"acodec": "opus",
"format": "250 - audio only (tiny)",
"format_note": "tiny",
"tbr": 76.443,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=250&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=audio%2Fwebm&gir=yes&clen=3854861&dur=591.401&lmt=1507622945308441&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIhALgR6NH1IAZwIk3MzFeJs5MSEtPXQ6ptzfS_c0-CowKbAiAWdGAB9JFCwtL39n8ee8AO_2atOlJyKU0W_9Tt1OENjA%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"abr": 70,
"asr": 48000,
"width": null
},
{
"height": null,
"filesize": 7065084,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "251",
"vcodec": "none",
"protocol": "https",
"ext": "webm",
"downloader_options": {
"http_chunk_size": 10485760
},
"acodec": "opus",
"format": "251 - audio only (tiny)",
"format_note": "tiny",
"tbr": 124.188,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=251&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=audio%2Fwebm&gir=yes&clen=7065084&dur=591.401&lmt=1507622947971155&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIgB4hAT4pF8aI6rI2q84eGG3IF2fIdO806JuGkv7ax8LACIQC7avZujeiNtmRZDEIzAWelxzJLYWqC75Gzik0Yhyjcrw%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"abr": 160,
"asr": 48000,
"width": null
},
{
"height": null,
"filesize": 9495914,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "140",
"container": "m4a_dash",
"protocol": "https",
"ext": "m4a",
"downloader_options": {
"http_chunk_size": 10485760
},
"acodec": "mp4a.40.2",
"format": "140 - audio only (tiny)",
"format_note": "tiny",
"vcodec": "none",
"tbr": 129.672,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=140&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=audio%2Fmp4&gir=yes&clen=9495914&dur=591.458&lmt=1415795872140674&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRAIgVEvtk7Bvo-dTP-QHZ90r12NYpLMnM7Ps1qp9PL563XMCIFoG5qllYYr_4l2CxVyMN_dtwsWv_HWbyrOk9kUUrdbh&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"abr": 128,
"asr": 44100,
"width": null
},
{
"height": 144,
"filesize": 5187560,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "278",
"container": "webm",
"protocol": "https",
"ext": "webm",
"format": "278 - 194x144 (144p)",
"fps": 30,
"format_note": "144p",
"tbr": 74.487,
"acodec": "none",
"downloader_options": {
"http_chunk_size": 10485760
},
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=278&aitags=133%2C160%2C242%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fwebm&gir=yes&clen=5187560&dur=591.367&lmt=1507623061784408&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIhAJGGF4cFF2qnvAjtO4lmJMkhlqR2UKzPUqbwaEv8rFsCAiBkiVT6XPHfxCbkyopAh4AiEPc9JtY5hbHtRuRBDnTvrA%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"width": 194,
"asr": null,
"vcodec": "vp9"
},
{
"height": 144,
"filesize": 7913960,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "160",
"protocol": "https",
"ext": "mp4",
"format": "160 - 194x144 (144p)",
"fps": 15,
"format_note": "144p",
"tbr": 113.723,
"acodec": "none",
"downloader_options": {
"http_chunk_size": 10485760
},
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=160&aitags=133%2C160%2C242%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fmp4&gir=yes&clen=7913960&dur=591.400&lmt=1415795873455728&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIhAIDs6R7ItsH5lM25V_dqN_yYFm_5mAc2gF6U_awc9sXxAiBu5Jrir1bgSXMsC7ZrnhpMJCts8PE0V9qcDrzySgMTpg%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"width": 194,
"asr": null,
"vcodec": "avc1.4d400c"
},
{
"height": 240,
"filesize": 8734238,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "242",
"protocol": "https",
"ext": "webm",
"format": "242 - 322x240 (240p)",
"fps": 30,
"format_note": "240p",
"tbr": 169.449,
"acodec": "none",
"downloader_options": {
"http_chunk_size": 10485760
},
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=242&aitags=133%2C160%2C242%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fwebm&gir=yes&clen=8734238&dur=591.367&lmt=1507623061440828&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIhAN7D8OkjklXr0AO_F1An8alz2mpJgys08pbtmrSePhD0AiBY_8JuGPizqdr70zqijdcmYS-NLWwDBAuQWcJxQrixLg%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"width": 322,
"asr": null,
"vcodec": "vp9"
},
{
"height": 240,
"filesize": 18043410,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "133",
"protocol": "https",
"ext": "mp4",
"format": "133 - 322x240 (240p)",
"fps": 30,
"format_note": "240p",
"tbr": 247.387,
"acodec": "none",
"downloader_options": {
"http_chunk_size": 10485760
},
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=133&aitags=133%2C160%2C242%2C278&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fmp4&gir=yes&clen=18043410&dur=591.366&lmt=1415795874677447&mt=1571330440&fvip=5&keepalive=yes&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=ALgxI2wwRQIgAmTNtcaK6cOtqjOHHPNlg3h-dPT-iDBQpCnvAVxEv2gCIQCUOw-KYpMdg2d3Xv1hEC8GMZpu1jDAXvxarBKTgmgJKQ%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D&ratebypass=yes",
"width": 322,
"asr": null,
"vcodec": "avc1.4d400d"
},
{
"height": 360,
"filesize": 21700774,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "43",
"protocol": "https",
"ext": "webm",
"tbr": null,
"format": "43 - 640x360 (360p)",
"acodec": "vorbis",
"format_note": "360p",
"width": 640,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=43&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fwebm&gir=yes&clen=21700774&ratebypass=yes&dur=0.000&lmt=1298436288017332&mt=1571330440&fvip=5&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRQIgEE0vAIDpN9JC4xFD4wTMvZwP7BrTPkJk-uMSw2g30H4CIQDU52N-7pFnM8cZgd1bchLRthcl6i6ZGbTCweZ61txrdg%3D%3D&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D",
"abr": 128,
"asr": null,
"vcodec": "vp8.0"
},
{
"height": 262,
"filesize": 26294671,
"http_headers": {
"Accept-Charset": "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.57 Safari/537.36",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "en-us,en;q=0.5"
},
"format_id": "18",
"protocol": "https",
"ext": "mp4",
"tbr": 355.714,
"format": "18 - 352x262 (240p)",
"acodec": "mp4a.40.2",
"format_note": "240p",
"width": 352,
"fps": null,
"player_url": null,
"url": "https://r2---sn-uigxx50n-8pxk.googlevideo.com/videoplayback?expire=1571352127&ei=35moXcuGLdqZ1gK7zqeACw&ip=178.115.128.175&id=o-AHlmX6ewQ0oGkLxHaBex7a7LhrxFyL7ROERRi9UiIYW6&itag=18&source=youtube&requiressl=yes&mm=31%2C29&mn=sn-uigxx50n-8pxk%2Csn-c0q7lnly&ms=au%2Crdu&mv=m&mvi=1&pl=20&initcwndbps=771250&mime=video%2Fmp4&gir=yes&clen=26294671&ratebypass=yes&dur=591.458&lmt=1415795880482368&mt=1571330440&fvip=5&fexp=23842630&c=WEB&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cmime%2Cgir%2Cclen%2Cratebypass%2Cdur%2Clmt&sig=ALgxI2wwRAIgY-EEHBbMKgL3IOtT574RJJNPZRQgYw3gZb682o8-TfQCIEwAsWs8FjYXX8mBZR_wRZlgz1XcGlfN1LCoVbYmhNu_&lsparams=mm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHylml4wRgIhANqY0o3uYDdDP-Ayajc9sWOgDH-9SUVNft9S78aFM3YqAiEA0MTAGAhSuXCGMun6oKkwCBnQ5r5sVLBK1MvH6Cr-gVs%3D",
"abr": 96,
"asr": 44100,
"vcodec": "avc1.42001E"
}
],
"format_note": "240p",
"webpage_url": "https://www.youtube.com/watch?v=Ahg8OBYixL0",
"alt_title": null,
"release_year": null,
"webpage_url_basename": "watch",
"format": "18 - 352x262 (240p)",
"fps": null,
"uploader_id": "enaiel",
"_filename": "The Star7 PDA Prototype-Ahg8OBYixL0.mp4",
"width": 352,
"chapters": null,
"view_count": 43611,
"thumbnails": [
{
"url": "https://i.ytimg.com/vi/Ahg8OBYixL0/hqdefault.jpg",
"id": "0"
}
],
"channel_id": "UC5hlZn3loBczMoU9KskruoA",
"is_live": null,
"display_id": "Ahg8OBYixL0",
"description": "The Star7 (*7) was a prototype for a SPARC based, handheld wireless PDA, with a 5\\" color LCD with touchscreen input, a new 16 bit --5:6:5 color hardware double buffered NTSC framebuffer, 900MHz wireless networking, PCMCIA bus interfaces, multi-media audio codec, a new power supply/battery interface, radical industrial design and packaging/process technology, a version of Unix that runs in under a megabyte, including drivers for PCMCIA, radio networking, touchscreen, display, flash RAM file system, execute-in-place, split I/D cache, with cached framebuffer support, a new small, safe, secure, distributed, robust, interpreted, garbage collected, multi-threaded, architecture neutral, high performance, dynamic programming language, a new small, fast, true-color alpha channel compositing, sprite graphics library, a set of classes that implement a spatial user interface metaphor, a user interface methodology which uses animation, audio, spatial cues, gestures, agency, color, and fun, a set of applications which show all of the features of the *7 hardware and software combination, including a TV guide, a fully functioning television remote control, a ShowMe style distributed whiteboard which allows active objects to be transmitted over a wireless network, and an on-screen agent which makes the whole experience fun and engaging.\\n\\nAll of this, in 1992! While the Star7 may have never entered commercial production, Oak, the language behind it all, became the very popular Java programming language.\\n\\nCopyright (c) Sun Microsystems.\\n\\nFor more information see:\\nhttps://duke.dev.java.net/green/\\nhttp://blogs.sun.com/jag/entry/the_green_ui",
"episode_number": null,
"extractor_key": "Youtube",
"title": "The Star7 PDA Prototype",
"acodec": "mp4a.40.2",
"dislike_count": 3,
"abr": 96,
"duration_string": "12:34:56",
"creator": null,
"filesize": 26294671,
"id": "Ahg8OBYixL0",
"vcodec": "avc1.42001E",
"license": null,
"fulltitle": "The Star7 PDA Prototype",
"annotations": null,
"start_time": null,
"channel_url": "http://www.youtube.com/channel/UC5hlZn3loBczMoU9KskruoA",
"ext": "mp4",
"player_url": null,
"album": null,
"asr": 44100,
"tbr": 355.714
}""")
new_mediafilename = self.guess_filename.handle_file(mediafile, False)
assert(type(new_mediafilename) == str)
new_mediafilename_generated = os.path.join(tmpdir, new_mediafilename)
new_mediafilename_comparison = os.path.join(tmpdir, "2007-09-13 youtube - The Star7 PDA Prototype - Ahg8OBYixL0 12;34;56.mp4")
self.assertEqual(new_mediafilename_generated, new_mediafilename_comparison)
os.remove(new_mediafilename_generated)
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'])
self.assertEqual(self.guess_filename.adding_tags([], ['bar']), ['bar'])
self.assertEqual(self.guess_filename.adding_tags(['foo'], ['bar', 'baz']), ['foo', 'bar', 'baz'])
self.assertEqual(self.guess_filename.adding_tags(['foo'], [42]), ['foo', 42])
def test_derive_new_filename_from_old_filename(self):
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-03-05 a1 12,34 €.pdf"),
"2016-03-05 A1 Festnetz-Internet 12,34€ -- scan bill.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-03-05 A1 12.34 EUR -- finance.pdf"),
"2016-03-05 A1 Festnetz-Internet 12.34€ -- finance scan bill.pdf")
# 2016-01-19--2016-02-12 benutzter GVB 10er Block -- scan transportation graz.pdf
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-03-05 10er.pdf"),
"2016-03-05 benutzter GVB 10er Block -- scan transportation graz.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-01-19--2016-02-12 10er GVB.pdf"),
"2016-01-19--2016-02-12 benutzter GVB 10er Block -- scan transportation graz.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-01-19--2016-02-12 10er GVB -- foobar.pdf"),
"2016-01-19--2016-02-12 benutzter GVB 10er Block -- foobar scan transportation graz.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-01-19 bill foobar baz 12,12EUR.pdf"),
"2016-01-19 foobar baz 12,12€ -- scan bill.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2016-03-12 another bill 34,55EUR.pdf"),
"2016-03-12 another 34,55€ -- scan bill.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12--2017-09-23 hipster.pdf"),
"2017-03-12--2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.pdf")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12--2017-09-23 hipster.png"),
"2017-03-12--2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.png")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12-2017-09-23 hipster.png"),
"2017-03-12-2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.png")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-03-12-2017-09-23 Hipster.png"),
"2017-03-12-2017-09-23 Hipster-PDA vollgeschrieben -- scan notes.png")
# rec_20171129-0902 A nice recording .wav -> 2017-11-29T09.02 A nice recording.wav
# rec_20171129-0902 A nice recording.wav -> 2017-11-29T09.02 A nice recording.wav
# rec_20171129-0902.wav -> 2017-11-29T09.02.wav
# rec_20171129-0902.mp3 -> 2017-11-29T09.02.mp3
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902 A nice recording .wav"),
"2017-11-29T09.02 A nice recording.wav")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902 A nice recording.wav"),
"2017-11-29T09.02 A nice recording.wav")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902.wav"),
"2017-11-29T09.02.wav")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("rec_20171129-0902.mp3"),
"2017-11-29T09.02.mp3")
# Screenshot_2017-11-29_10-32-12.png
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("Screenshot_2017-11-29_10-32-12.png"),
"2017-11-29T10.32.12 -- screenshots.png")
# Screenshot_2017-11-07_07-52-59 my description.png
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("Screenshot_2017-11-29_10-32-12 my description.png"),
"2017-11-29T10.32.12 my description -- screenshots.png")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-11-14_16-10_Tue.gpx"),
"2017-11-14T16.10.gpx")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-12-07_09-23_Thu Went for a walk .gpx"),
"2017-12-07T09.23 Went for a walk.gpx")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2017-11-03_07-29_Fri Bicycling.gpx"),
"2017-11-03T07.29 Bicycling.gpx")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("2015-05-27T09;00;15_foo_bar.gpx"),
"2015-05-27T09.00.15 foo bar.gpx")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180510T090000 ORF - ZIB - Signation -ORIGINAL- 2018-05-10_0900_tl_02_ZIB-9-00_Signation__13976423__o__1368225677__s14297692_2__WEB03HD_09000305P_09001400P_Q4A.mp4"),
"2018-05-10T09.00.03 ORF - ZIB - Signation -- lowquality.mp4")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180510T090000 ORF - ZIB - Weitere Signale der Entspannung -ORIGINAL- 2018-05-10_0900_tl_02_ZIB-9-00_Weitere-Signale__13976423__o__5968792755__s14297694_4__WEB03HD_09011813P_09020710P_Q4A.mp4"),
"2018-05-10T09.01.18 ORF - ZIB - Weitere Signale der Entspannung -- lowquality.mp4")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180520T201500 ORF - Tatort - Tatort_ Aus der Tiefe der Zeit -ORIGINAL- 2018-05-20_2015_in_02_Tatort--Aus-der_____13977411__o__1151703583__s14303062_Q8C.mp4"),
"2018-05-20T20.15.00 ORF - Tatort Aus der Tiefe der Zeit -- highquality.mp4")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180521T193000 ORF - ZIB 1 - Parlament bereitet sich auf EU-Vorsitz vor -ORIGINAL- 2018-05-21_1930_tl_02_ZIB-1_Parlament-berei__13977453__o__277886215b__s14303762_2__WEB03HD_19350304P_19371319P_Q4A.mp4"),
"2018-05-21T19.35.03 ORF - ZIB 1 - Parlament bereitet sich auf EU-Vorsitz vor -- lowquality.mp4")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190902T220000 ORF - ZIB 2 - Bericht über versteckte ÖVP-Wahlkampfkosten -ORIGINALlow- 2019-09-02_2200_tl_02_ZIB-2_Bericht-ueber-v__14024705__o__71528285d6__s14552793_3__ORF2HD_22033714P_22074303P_Q4A.mp4'),
'2019-09-02T22.03.37 ORF - ZIB 2 - Bericht über versteckte ÖVP-Wahlkampfkosten -- lowquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190902T220000 ORF - ZIB 2 - Hinweis _ Verabschiedung -ORIGINALlow- 2019-09-02_2200_tl_02_ZIB-2_Hinweis---Verab__14024705__o__857007705d__s14552799_9__ORF2HD_22285706P_22300818P_Q4A.mp4'),
'2019-09-02T22.28.57 ORF - ZIB 2 - Hinweis Verabschiedung -- lowquality.mp4')
# NOTE: if you add test cases, you have to add the file name to __init__.py > get_file_size() as well in order to overrule the file size check which would fail in any case!
# self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename(''),
# '')
# ORF file not truncated but still without detailed time-stamps
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180608T193000 ORF - Österreich Heute - Das Magazin - Österreich Heute - Das Magazin -ORIGINAL- 13979231_0007_Q8C.mp4"),
"2018-06-08T19.30.00 ORF - Österreich Heute - Das Magazin - Österreich Heute - Das Magazin -- highquality.mp4")
# plausibility checks of file sizes: report plausible sizes
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180608T170000 ORF - ZIB 17_00 - size okay -ORIGINAL- 2018-06-08_1700_tl__13979222__o__1892278656__s14313181_1__WEB03HD_17020613P_17024324P_Q4A.mp4"),
"2018-06-08T17.02.06 ORF - ZIB 17 00 - size okay -- lowquality.mp4")
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename("20180608T170000 ORF - ZIB 17_00 - size okay -ORIGINAL- 2018-06-08_1700_tl__13979222__o__1892278656__s14313181_1__WEB03HD_17020613P_17024324P_Q8C.mp4"),
"2018-06-08T17.02.06 ORF - ZIB 17 00 - size okay -- highquality.mp4")
# plausibility checks of file sizes: report non-plausible sizes
#FIXXME: 2019-09-03: tests disabled because the function was disabled and never raises the expected exception
#with self.assertRaises(FileSizePlausibilityException, message='file size is not plausible (too small)'):
# self.guess_filename.derive_new_filename_from_old_filename("20180608T170000 ORF - ZIB 17_00 - size not okay -ORIGINAL- 2018-06-08_1700_tl__13979222__o__1892278656__s14313181_1__WEB03HD_17020613P_18024324P_Q4A.mp4")
#with self.assertRaises(FileSizePlausibilityException, message='file size is not plausible (too small)'):
# self.guess_filename.derive_new_filename_from_old_filename("20180608T170000 ORF - ZIB 17_00 - size not okay -ORIGINAL- 2018-06-08_1700_tl__13979222__o__1892278656__s14313181_1__WEB03HD_17020613P_18024324P_Q8C.mp4")
# You might think that it should be 2018-06-09 instead of 2018-06-10. This is caused by different
# day of metadata from filename (after midnight) and metadata from time-stamp (seconds before midnight):
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20180610T000000 ORF - Kleinkunst - Kleinkunst_ Cordoba - Das Rückspiel (2_2) -ORIGINAL- 2018-06-10_0000_sd_06_Kleinkunst--Cor_____13979381__o__1483927235__s14313621_1__ORF3HD_23592020P_00593103P_Q8C.mp4'),
'2018-06-10T23.59.20 ORF - Kleinkunst - Kleinkunst Cordoba - Das Rückspiel (2 2) -- highquality.mp4')
# Original ORF TV Mediathek download file names (as a fall-back for raw download using wget or curl):
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2018-06-14_2105_sd_02_Am-Schauplatz_-_Alles für die Katz-_____13979879__o__1907287074__s14316407_7__WEB03HD_21050604P_21533212P_Q8C.mp4'),
'2018-06-14T21.05.06 Am Schauplatz - Alles für die Katz -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2018-06-14_2155_sd_06_Kottan-ermittelt - Wien Mitte_____13979903__o__1460660672__s14316392_2__ORF3HD_21570716P_23260915P_Q8C.mp4'),
'2018-06-14T21.57.07 Kottan ermittelt - Wien Mitte -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2018-06-14_2330_sd_06_Sommerkabarett - Lukas Resetarits: Schmäh (1 von 2)_____13979992__o__1310584704__s14316464_4__ORF3HD_23301620P_00302415P_Q8C.mp4'),
'2018-06-14T23.30.16 Sommerkabarett - Lukas Resetarits: Schmäh (1 von 2) -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-09-29_2255_sd_02_Das-Naturhistor_____14027337__o__1412900222__s14566948_8__ORF2HD_23152318P_00005522P_Q8C.mp4/playlist.m3u8'),
'2019-09-29T23.15.23 Das Naturhistor -- highquality.mp4')
# the file name did NOT contain the optional chunk time-stamp(s), so we have to use the main time-stamp
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190902T220000 ORF - ZIB 2 - Bericht über versteckte ÖVP-Wahlkampfkosten -ORIGINALlow- 2019-09-02_2200_tl_02_ZIB-2_Bericht-ueber-v__14024705__o__71528285d6__xxx_Q4A.mp4'),
'2019-09-02T22.00.00 ORF - ZIB 2 - Bericht über versteckte ÖVP-Wahlkampfkosten -- lowquality.mp4')
# ORF TV Mediathek as of 2018-11-01: when there is no original filename with %N, I have to use the data I've got
# see https://github.com/mediathekview/MServer/issues/436
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181028T201400 ORF - Tatort - Tatort Blut -ORIGINALhd- playlist.m3u8.mp4'),
'2018-10-28T20.14.00 ORF - Tatort Blut -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181028T201400 ORF - Tatort - Tatort Blut -ORIGINALlow- playlist.m3u8.mp4'),
'2018-10-28T20.14.00 ORF - Tatort Blut -- lowquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181022T211100 ORF - Thema - Das Essen der Zukunft -ORIGINALhd- playlist.m3u8.mp4'),
'2018-10-22T21.11.00 ORF - Thema - Das Essen der Zukunft -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181022T211100 ORF - Thema - Das Essen der Zukunft -ORIGINALlow- playlist.m3u8.mp4'),
'2018-10-22T21.11.00 ORF - Thema - Das Essen der Zukunft -- lowquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181025T210500 ORF - Am Schauplatz - Am Schauplatz Wenn alles zusammenbricht -ORIGINALhd- playlist.m3u8.mp4'),
'2018-10-25T21.05.00 ORF - Am Schauplatz Wenn alles zusammenbricht -- highquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181025T210500 ORF - Am Schauplatz - Am Schauplatz Wenn alles zusammenbricht -ORIGINALlow- playlist.m3u8.mp4'),
'2018-10-25T21.05.00 ORF - Am Schauplatz Wenn alles zusammenbricht -- lowquality.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20181025T210500 ORF - Am Schauplatz Wenn alles zusammenbricht - Am Schauplatz -ORIGINALlow- playlist.m3u8.mp4'),
'2018-10-25T21.05.00 ORF - Am Schauplatz Wenn alles zusammenbricht -- lowquality.mp4')
## ORF TV Mediathek as of 2023-03-05:
## 20230303T232946 ORF - Gute Nacht Österreich mit Peter Klien - Wirtschaftliche Probleme in Großbritannien -ORIGINALlow- 2023-03-03_2329_tl_01_Gute-Nacht-Oest_Wirtschaftliche__14170146__o__3365936366__s15349885_5__ORF1HD_00005621P_00105414P_Q4A.mp4
## 2023-03-04T00.00.56 ORF - Gute Nacht Österreich mit Peter Klien - Wirtschaftliche Probleme in Großbritannien -- lowquality.mp4
## ... the day should be incremented because this did start shortly before midnight but this part was started after midnight
## When the actual start time (2nd timestamp in filename) is older than 10 hours compared to the file name start time, assume it is actually started after midnight.
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20230303T232946 ORF - Gute Nacht Österreich mit Peter Klien - Wirtschaftliche Probleme in Großbritannien -ORIGINALlow- 2023-03-03_2329_tl_01_Gute-Nacht-Oest_Wirtschaftliche__14170146__o__3365936366__s15349885_5__ORF1HD_00005621P_00105414P_Q4A.mp4'),
'2023-03-04T00.00.56 ORF - Gute Nacht Österreich mit Peter Klien - Wirtschaftliche Probleme in Großbritannien -- lowquality.mp4')
# Digital camera from Android
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('IMG_20190118_133928.jpg'),
'2019-01-18T13.39.28.jpg')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('IMG_20190118_133928 This is a note.jpg'),
'2019-01-18T13.39.28 This is a note.jpg')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('IMG_20190118_133928_Bokeh.jpg'),
'2019-01-18T13.39.28 Bokeh.jpg')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('IMG_20190118_133928_Bokeh This is a note.jpg'),
'2019-01-18T13.39.28 Bokeh This is a note.jpg')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('VID_20170105_173104.mp4'),
'2017-01-05T17.31.04.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('VID_20170105_173104 foo bar.mp4'),
'2017-01-05T17.31.04 foo bar.mp4')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2-Exported.pdf'),
'2019-10-10 a file exported by Boox Max 2 -- notes.pdf')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2 -- notes-Exported.pdf'),
'2019-10-10 a file exported by Boox Max 2 -- notes.pdf')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2019-10-10 a file exported by Boox Max 2 -- draft-Exported.pdf'),
'2019-10-10 a file exported by Boox Max 2 -- draft notes.pdf')
# Smartrecorder
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190512-1125_Recording_1.wav'),
'2019-05-12T11.25 Recording 1.wav')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190512-1125_Recording_1.mp3'),
'2019-05-12T11.25 Recording 1.mp3')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190512-1125.wav'),
'2019-05-12T11.25.wav')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('20190512-1125.mp3'),
'2019-05-12T11.25.mp3')
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('Die Presse (31.10.2019) - Unknown.pdf'),
'2019-10-31 Die Presse.pdf')
# signal-2018-03-08-102332.jpg → 2018-03-08T10.23.32.jpg
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('signal-2018-03-08-102332.jpg'),
'2018-03-08T10.23.32.jpg')
# signal-2018-03-08-102332 foo bar.jpg → 2018-03-08T10.23.32 foo bar.jpg
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('signal-2018-03-08-102332 foo bar.jpg'),
'2018-03-08T10.23.32 foo bar.jpg')
# signal-attachment-2019-11-23-090716_001.jpeg -> 2019-11-23T09.07.16_001.jpeg
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('signal-attachment-2019-11-23-090716_001.jpeg'),
'2019-11-23T09.07.16 001.jpeg')
# modet_2018-03-27_16-10.mkv
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('modet_2018-03-27_16-10.mkv'),
'2018-03-27T16.10 modet.mkv')
# modet_2018-03-27_17-44-1.mkv
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('modet_2018-03-27_17-44-1.mkv'),
'2018-03-27T17.44 modet -1.mkv')
# C110014365208EUR20150930001.pdf -> 2015-09-30 Bank Austria Kontoauszug 2015-001 10014365208.pdf
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('C110014365208EUR20150930001.pdf'),
'2015-09-30 Bank Austria Kontoauszug 2015-001 10014365208.pdf')
# 2017-11-05T10.56.11_IKS-00000000512345678901234567890.csv -> 2017-11-05T10.56.11 Bank Austria Umsatzliste IKS-00000000512345678901234567890.csv
self.assertEqual(self.guess_filename.derive_new_filename_from_old_filename('2017-11-05T10.56.11_IKS-00000000512345678901234567890.csv'),
'2017-11-05T10.56.11 Bank Austria Umsatzliste IKS-00000000512345678901234567890.csv')