MediaElch icon indicating copy to clipboard operation
MediaElch copied to clipboard

Movie folder timestamp is updated to the current date when a movie is scraped

Open doublehelix opened this issue 1 year ago • 4 comments

Describe the bug When scraping movies, the folder for the movie is updated to the current timestamp. This causes media libraries/apps to recognize my entire library as "Recently Added". Ordinarily, when i add a new movie to my collection, recently added includes only those which are actually recently added, not just recently scraped.

I made the mistake of scraping my entire library.... now I have no history of what's new and what's old.

At the least, there should be an option to DISABLE the timestamp being changed if the user wishes to maintain the existing historical timestamps. (For comparison, EmberMediaManager does not change timestamps when scraping)

To Reproduce Steps to reproduce the behavior:

  1. Scrape any movie

Expected behavior

  • .nfo files may be updated
  • Images may be downloaded
  • The timestamp of the parent folder should NOT change.

Screenshots If applicable, add screenshots to help explain your problem.

MediaElch Version:

  • [ ] 2.10.7-dev (nightly)
  • [x] 2.10.6 (stable)

Operating System:

  • [x] Windows
  • [ ] macOS
  • [ ] Linux (distribution: .)

Additional context Storage device is a QNAP NAS. As a comparison, Ember Media manager does not alter folder timestamps when scraping.

doublehelix avatar Dec 07 '23 23:12 doublehelix

Hi,

thank you for bringing this up. It was never something that occurred to me as an issue.

Just a few notes:

  1. the movie's timestamp shouldn't be changed, correct (i.e. the mp4, mov, ... file)
  2. the containing folder's timestamp is updated
  3. the NFO file's timestamp is updated (or the file is created for the first time)

And you'd like (2) to not happen: Even if a file inside was changed, the modification date should stay the same. Did I get that correctly? :smile:

I never thought about this. I didn't even know that was an option. (note to self: see e.g. https://doc.qt.io/qt-5/qfiledevice.html#setFileTime ).

Regards, Andre

bugwelle avatar Dec 09 '23 12:12 bugwelle

Hi, sorry for the delayed response. Was just updating my folders again today.

Yes... item 2 is definitely a problem for some software.

Unfortunately Plex, Kodi, and Infuse (on iOS), all seem to use the timestamp of the folder to determine "recently added" movies and shows. (it ignores the timestamp of the media file and nfo itself)

"Recently Added" is how we see "new" stuff regardless of the release date of the movie itself.

doublehelix avatar May 14 '24 02:05 doublehelix

Hi, sorry for the delayed response.

Don't worry. I'm a bit slow with my responses, too. See https://github.com/Komet/MediaElch/issues/1710


Regarding your issue:

Linux

At least on Linux, it appears to be on purpose that the directory's "last modified date" is changed when a movie is scraped, because we add files and add new subdirectories. To quote from StackOverflow:

The mtime (modification time) on the directory itself changes when a file or a subdirectory is added, removed or renamed.

Modifying the contents of a file within the directory does not change the directory itself, nor does updating the modified times of a file or a subdirectory. Additionally, adding, removing or renaming files/directories in subdirectories does not propagate up to the directory. If you change the permissions on the directory, the ctime changes but the mtime does not.

If we don't want to change the directory's date, we'd have to first save the date in a variable, change all files, and then reset the directory's "last modified"-date.

Windows

On Windows with NTFS, the rules seem to be described in https://stackoverflow.com/a/46428666/1603627 . They look similar to Linux's rules.


In short: MediaElch adds files when first scraping a movie. Those files include the NFO file, but also the .actors subdirectory. These newly added files lead to the "last modified date" being updated.

If MediaElch were to reset these dates (assuming that's even possible), then we'd work around a filesystem feature. I'm hesitant to change that behavior. But even if we were to reset the date: We would probably need to handle all parent directories up to the root.

But it may be that I'm missing something obvious. I'm not a Windows user myself. I'll have to look at https://github.com/DanCooper/Ember-MM-Newscraper/ and see how they do it.

If there is a user who knows more about this topic, feel free to ping me or reply. :)

Regards, Andre

bugwelle avatar May 18 '24 13:05 bugwelle

Thanks for the feedback. This makes total sense (especially when the files are on linux/nas storage) It's potentially even something these apps need to make an option (folder vs. media file timestamp).

doublehelix avatar May 20 '24 01:05 doublehelix