Error parsing Recorded_date

Support for Windows users
Post Reply
mvdveek
Posts: 2
Joined: 11 Aug 2021, 21:33

Error parsing Recorded_date

Post by mvdveek »

I'm trying to rename some mp4 files. The new name is based on the recorded_date field from mediainfo

This is the command I use:

Code: Select all

filebot -rename -r "1.mp4" --format "{media.Recorded_date.format('yyyy-MM-dd_HHmmss')}_{f.dir.name}_{dc.pad(5)}"
This gives me the following error:

Code: Select all

Classify media files
Failed to parse media property: MediaTags: 1.mp4: java.time.format.DateTimeParseException: 2020-09-01T16:44:52+0200
* Consider specifying --db TheTVDB or --db TheMovieDB explicitly
Rename movies using [TheMovieDB]
Auto-detect movie from context [1.mp4]
Name (Year) movie pattern not found: 1.mp4
* Consider using -non-strict to enable opportunistic matching
Failed to process group: {Movie=The Core (2003)} [1.mp4]
└ Failed to identify or process any files
Failed to parse media property: MediaTags: 1.mp4: java.time.format.DateTimeParseException: 2020-09-01T16:44:52+0200

There are 2 things i'm looking to fix.
Obviously the DateTimeParseException.
And I dont want my command to check for movie matches. I just want it to use my format rule.

What should I need to change?

Here is my sysinfo

Code: Select all

FileBot 4.9.4 (r8736)
JNA Native: 6.1.0
MediaInfo: 20.09
7-Zip-JBinding: 16.02
Tools: fpcalc/1.5.0
Extended Attributes: OK
Unicode Filesystem: OK
Script Bundle: 2021-08-02 (r761)
Groovy: 3.0.8
JRE: OpenJDK Runtime Environment 16.0.2
JVM: 64-bit OpenJDK 64-Bit Server VM
CPU/MEM: 6 Core / 4.3 GB Max Memory / 38 MB Used Memory
OS: Windows 10 (amd64)
HW: CYGWIN_NT-10.0 DESKTOP 3.2.0(0.340/5/3) 2021-03-29 08:42 x86_64 Cygwin
DATA: \AppData\Roaming\FileBot
Package: MSI
License: UNREGISTERED
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Error parsing Recorded_date

Post by rednoah »

1.
media.RecordedDate is a String value, so you'll have to first parse it into a Date object before you can call Date.format() on it.


2.
Plain File Mode (i.e. --db file) allows you to process files without matching.


:idea: Coincidentally, Plain File Mode has an example for parsing date time values and reformatting them, so you can repurpose code to your needs:
rednoah wrote: 13 Oct 2014, 21:47 Pre-Process badly named episode files

FileBot cannot process badly named files like B&B Aug 4 - 14 so you will need to fix it first. The Bold and The Beautiful - 2014.08.04 is much more sensible.

Code: Select all

{Date.parse('MMM dd - yy', fn.after(/\s/)).format('yyyy.MM.dd')}
Extract, parse and re-format the date.
Image



EDIT:

3.
Note that this warning likely occurs during Movie / Series auto-detection and is therefore completely unrelated to any of the above:

Code: Select all

Classify media files
Failed to parse media property: MediaTags: 1.mp4: java.time.format.DateTimeParseException: 2020-09-01T16:44:52+0200
...

:arrow: However, related to the task at hand, this warning message does give us some test data to work with, so here's how you'd parse and reformat a date value like that:

Code: Select all

{
	def text = '2020-09-01T16:44:52+0200'
	def date = text.parseDate(/uuuu-MM-dd'T'HH:mm:ss[X]/)
	return date.format(/yyyy-MM-dd_HHmmss/)
}
:idea: Please read the FAQ and How to Request Help.
mvdveek
Posts: 2
Joined: 11 Aug 2021, 21:33

Re: Error parsing Recorded_date

Post by mvdveek »

This gave me a lot to think about.

I changed my call to go via a groovy script

Code: Select all

filebot -script test.groovy "1.mp4" --db file

Code: Select all

#!/usr/bin/env filebot -script

// log input parameters
log.fine("Run script [$_args.script] at [$now]")

def dateFormatted
def parentDir = args.dir.name[0]

args.files.each{ f ->
	MediaInfo.snapshot(f).each{ kind, streams ->
		streams.each{ p ->
			p.each{ k,v -> 
				if(k == 'Recorded_Date') {
					def date = v.parseDate(/uuuu-MM-dd'T'HH:mm:ss[X]/)
					dateFormatted = date.format(/yyyy-MM-dd_HHmmss/)
				}
			}
		}
	}
}

if(dateFormatted) {
	println "${dateFormatted}_${parentDir}_mobiel"
	rename(file:args, format: "${dateFormatted}_${parentDir}_mobiel")
}
But this still gives me a

Code: Select all

Invalid format expression: 2020-09-01_164452_tmp_mobiel
Is there a way to just give a specific value to the rename function?
Or is this not the best approach for what I want to achieve?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Error parsing Recorded_date

Post by rednoah »

I don't really understand your code, but based on the OP I suppose you'd use Plain File Mode and do something like this:

Code: Select all

$ filebot -rename "Test" --db file --format "{ media.RecordedDate.match(/\d+-\d+-\d+/) }_{ media.RecordedDate.match(/\d+:\d+:\d+/).colon('') }_{folder.name}_XYZ" --action TEST --log INFO
[TEST] from [Test/a.mp4] to [Test/2011-11-12_210000_Test_XYZ.mp4]

:idea: media.RecordedDate could be any String value, and isn't guaranteed to be any particular date/time format, so it's best to just match the information we need as generically as possible:

Code: Select all

{ media.RecordedDate.match(/\d+-\d+-\d+/) }

Code: Select all

{ media.RecordedDate.match(/\d+:\d+:\d+/).colon('') }
:idea: Please read the FAQ and How to Request Help.
seibop
Posts: 18
Joined: 08 Mar 2020, 13:33

Re: Error parsing Recorded_date

Post by seibop »

I've had the same (similar error) Filebot CLI using AMC says:

Code: Select all

filebot -script fn:amc --output "d:\media" --action move --conflict auto -non-strict --def unsorted=y music=n artwork=y extras=y --def skipExtract=y --def clean=y -r  --def minFileSize=2 --def minLengthMS=2 d:\tv1
Works for the super majority just fine, but some return (such as)

Code: Select all

Failed to parse media property: MediaTags: D:\tv1\American Ninja Warrior\Season 08\American Ninja Warrior - S08E07 - Atlanta Finals.mp4: java.time.format.DateTimeParseException: 2016-07-18T05:00:00
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Error parsing Recorded_date

Post by rednoah »

That's just a warning message. Just ignore. Newer versions of FileBot will take this date format as well. Just means that the encoding library used a non-standard date/time pattern for for the recorded_date metadata field when the file was created.



:idea: Note that --def minFileSize=2 --def minLengthMS=2 means 2 bytes and 2 milliseconds so that seems a bit pointless. I'd use values in the megabyte / minutes range, or 0 for disabling file size / video length limits altogether.
:idea: Please read the FAQ and How to Request Help.
Post Reply