Metadata and Extended Attributes

How-to guides, frequently asked questions, not-so-obvious features, etc
Locked
User avatar
rednoah
The Source
Posts: 22836
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Metadata and Extended Attributes

Post by rednoah »

FileBot uses xattr (i.e. Extended Attributes / NTFS Alternate Data Streams) to store full metadata in file system attributes. These xattr are not to be confused with traditional tags that are embedded in the file content, but additional data streams stored in the file system for each file that are not part of the file itself. As such, xattr requires a filesystem that supports xattr, and xattr may be silently lost if files are moved to a filesystem that doesn't support xattr.


Attributes

Screenshot




Usage

FileBot and other programs have the original filename and all episode / movie metadata available regardless how the file is named. Sure nice to have full metadata instantly / offline available should you need it. Please read Plain File Mode and Re-organize previously organized files using local xattr metadata for details and examples on how to re-match files to previously stored xattr metadata.


Disable this feature via the -no-xattr command-line flag:

Shell: Select all

-no-xattr
or via system properties:

Shell: Select all

filebot -script fn:properties --def useExtendedFileAttributes=false

:idea: Configure FileBot to store xattr metadata in plain text files instead of filesystem xattr streams:

Shell: Select all

filebot -script fn:properties --def net.filebot.xattr.store=.xattr
:idea: You can specify an absolute path to store xattr metadata for all files in one folder:

Shell: Select all

filebot -script fn:properties --def net.filebot.xattr.store=/path/to/.metadata
:idea: If you require cross-platform compatibility (e.g. write metadata from a Windows client to a SMB network share and then read that metadata from the local file system on the Linux host or vice versa) then using .xattr folders and files is highly recommended. Please read Optimizations for Remote File Systems for details.


:idea: Unset the net.filebot.xattr.store property to restore the original behaviour:

Shell: Select all

filebot -script fn:properties --def net.filebot.xattr.store=



View or Clear Extended Attributes
with the filebot command-line tool:

View xattr for files:

Shell: Select all

filebot -script fn:xattr /path/to/files
Set xattr on files:

Shell: Select all

filebot -script fn:xattr /path/to/files --def name="value"
Unset xattr on files:

Shell: Select all

filebot -script fn:xattr /path/to/files --def net.filebot.mediainfo= net.filebot.mediainfo.mtime=
Clear xattr from files:

Shell: Select all

filebot -script fn:xattr /path/to/files --action clear
Prune orphaned .xattr folders where the corresponding media file no longer exists:

Shell: Select all

filebot -script fn:xattr /path/to/files --action prune
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22836
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

View or Clear Extended Attributes

Post by rednoah »

If Extended Attributes are enabled and supported by your file system, then FileBot will the store original file name and episode / movie metadata into Extended Attributes for future reference by FileBot or other applications.


e.g. write xattr:

Console Output: Select all

$ filebot -rename . --db TheTVDB -non-strict --log INFO
[MOVE] from [Alias.1x01.mp4] to [Alias - 1x01 - Truth Be Told.mp4]

e.g. read xattr:

Console Output: Select all

$ filebot -script fn:xattr .
Alias - 1x01 - Truth Be Told.mp4
	net.filebot.filename: Alias.1x01.mp4
	net.filebot.metadata: {"@type":"Episode","seriesName":"Alias","season":1,"episode":1,"title":"Truth Be Told","airdate":{"year":2001,"month":9,"day":30},"id":180267,"seriesInfo":{"database":"TheTVDB","order":"Airdate","language":"en","type":"TV Series","id":75930,"name":"Alias","aliasNames":["Alias - Die Agentin","Alias (2001)","זהות בדויה","Alias - Codinome Perigo","Шпионка","特務A"],"certification":"TV-14","startDate":{"year":2001,"month":9,"day":30},"genres":["Action","Adventure","Drama","Suspense"],"network":"ABC (US)","rating":8.2,"ratingCount":3316,"runtime":45,"status":"Ended"}}

e.g. read xattr with 3rd party tools:

Console Output: Select all

$ xattr -p net.filebot.metadata *.mp4 | jsonpp
{
  "@type": "Episode",
  "seriesName": "Alias",
  "season": 1,
  "episode": 1,
  "title": "Truth Be Told",
  "airdate": {
    "year": 2001,
    "month": 9,
    "day": 30
  },
  "id": 180267,
  "seriesInfo": {
    "database": "TheTVDB",
    "order": "Airdate",
    "language": "en",
    "type": "TV Series",
    "id": 75930,
    "name": "Alias",
    "aliasNames": [
      "Alias - Die Agentin",
      "Alias (2001)",
      "זהות בדויה",
      "Alias - Codinome Perigo",
      "Шпионка",
      "特務A"
    ],
    "certification": "TV-14",
    "startDate": {
      "year": 2001,
      "month": 9,
      "day": 30
    },
    "genres": [
      "Action",
      "Adventure",
      "Drama",
      "Suspense"
    ],
    "network": "ABC (US)",
    "rating": 8.2,
    "ratingCount": 3316,
    "runtime": 45,
    "status": "Ended"
  }
}

e.g. read xattr via our xattr.py python script:

Console Output: Select all

$ python xattr.py *.mp4 net.filebot.metadata
...


:arrow: Please read Plain File Mode and Re-organize previously organized files using local xattr metadata for details and examples on how to re-match files to previously stored xattr metadata.
:idea: Please read the FAQ and How to Request Help.
Locked