EltonChou / TwitterMediaHarvest

Download twitter media with only one-click.
https://chrome.google.com/webstore/detail/media-harvest-twitter-med/hpcgabhdlnapolkkjpejieegfpehfdok
MIT License
427 stars 36 forks source link

[FEATURE] Set file modified time to tweet time #80

Closed fireattack closed 1 year ago

fireattack commented 1 year ago

Is your feature request related to a problem? Please describe.

Set the modified time of downloaded items to its tweet time.

Additional context

It is very useful to manage large amount of medias. You can sort by filename to group files by username and sort by modified date to order them in chronological order.

I don't know if it's even possible with download API, though.

EltonChou commented 1 year ago

The modified time was managed by the browser or the file system, extension can't specify them.

This feature might be related to #55 . Feel free to share you ideas!

fireattack commented 1 year ago

Thanks.

As soon as we can add datetime to the filename (after #74), I can at least use a local script to modify them in batch, so not a big deal (which is also to say that timestamp is definitely not useless in filename).

EltonChou commented 1 year ago

I will add some pattern tokens in next patch. image

Can you share the scenario how do you use the timestamp in filename? In the most of file system, the modified time would be managed by system.

fireattack commented 1 year ago

You can always modify them manually:

Like in Python:

from os import utime
from datetime import datetime
from pathlib import Path

def update_mtime(f, mtime=None):
    f = Path(f)
    if mtime is None:
        mtime = datetime.now()

    current_mtime = datetime.fromtimestamp(f.stat().st_mtime)
    print(f'{f.name}: {current_mtime.isoformat()} -> {mtime.isoformat()}')
    mtime_unix = int(mtime.timestamp())
    utime(f, (mtime_unix, mtime_unix))

(You can even modify creation time, but that's more complicated.)

EltonChou commented 1 year ago

Tweet time pattern was introduced in v4.1.5.