jdaymude / xbox2local

A command line utility for downloading Xbox screenshots and game clips to local storage
MIT License
8 stars 2 forks source link

Implement 22 #23

Closed ktiedt closed 1 year ago

ktiedt commented 1 year ago

This was a very rough work around, in my opinion, but it does work. You can see the results of this in the attached screenshot. These files were downloaded yesterday after patching my local copy with this change.

Screen Shot 2023-04-02 at 12 38 23 PM
jdaymude commented 1 year ago

Some notes to self for the updated implementation of this feature (to be finished in the next couple days). TL;DR: I should be able to make this feature work fully for Windows and partially on Linux. macOS seems to be somewhere in between.

The proposed implementation uses the filedate package for python to set the access, modification, and creation dates of an existing file. However, (1) this package is a simple wrapper around basic python that could be implemented directly, and (2) this package is not entirely honest about its own limitations which should be documented clearly. I intend to implement something directly into xbox2local to get this feature without adding a dependency.

As best summarized here, there is no consistent, cross-platform way of accessing and/or modifying all three types of file dates.

A file's access time can be accessed using os.stat().st_atime and its modification time can be accessed using either os.stat().st_mtime or os.path.getmtime(). The access and modification times can be modified simultaneously using os.utime() as described here with examples.

File creation times have different rule sets across Windows, macOS, and Linux.

ktiedt commented 1 year ago

I was testing on macOS so it was definitely working there. Great notes though. Thanks again!

jdaymude commented 1 year ago

Addressed by #24, and will be included in an upcoming v2.1.

I was able to get this functionality with just a couple lines of code (without adding the filedate dependency). I also added a new function you can run in update.py to apply capture datetimes to all previously downloaded media without having to delete/redownload them.