Python daemon to watch a folder and update a database

后端 未结 3 1268
予麋鹿
予麋鹿 2021-02-06 15:08

This is specifically geared towards managing MP3 files, but it should easily work for any directory structure with a lot of files.

I want to find or write a daemon (pref

相关标签:
3条回答
  • 2021-02-06 15:36

    If you use Linux, you can use PyInotify.

    inotify can notify you about filesystem events when your program is running.

    0 讨论(0)
  • 2021-02-06 15:37

    Another answer already suggested pyinotify for Linux, let me add watch_directory for Windows (a good discussion of the possibilities in Windows is here, the module's an example) and fsevents on the Mac (unfortunately I don't think there's a single cross-platform module offering a uniform interface to these various system-specific ways to get directory-change notification events).

    Once you manage to get such events, updating an appropriate SQL database is simple!-)

    0 讨论(0)
  • 2021-02-06 15:45

    IMO, the best media player that has these features is Winamp. It rescans the music folders every X minutes, which is enough for music (but of course a little less efficient than letting the operating system watch for changes).

    But as you were asking for suggestions on writing your own, you could make use of pyinotify (Linux only). If you're running Windows, you can use the ReadDirectoryChangesW API call

    0 讨论(0)
提交回复
热议问题