#53 Add a default config file to prismedia

Open
opened 3 years ago by LecygneNoir · 4 comments
Owner

In order to make even easier the use of NFO, and now that prismedia is a binary installable via pip, we may add a default configuration file!

Something like /etc/prismedia/config.txt where you can specify all defaults, like any NFO, and where prismedia could look for settings before any NFO

It will also allow us to add some default option for prismedia, instead of hardcoded them.

We need to see if a multi-OS library exist to deal with that, something like https://crates.io/crates/directories-next for Rust, as /etc/prismedia is relevant only for Linux.

In order to make even easier the use of NFO, and now that prismedia is a binary installable via pip, we may add a default configuration file! Something like `/etc/prismedia/config.txt` where you can specify all defaults, like any NFO, and where prismedia could look for settings before any NFO It will also allow us to add some default option for prismedia, instead of hardcoded them. We need to see if a multi-OS library exist to deal with that, something like https://crates.io/crates/directories-next for Rust, as `/etc/prismedia` is relevant only for Linux.
LecygneNoir added the
Todo
label 3 years ago
Zykino commented 3 years ago
Poster

After asking #python-fr on Freenode’s IRC we got to the conclusion that no lib appears to exist in pypi. Also the right thing to do for each platform seems to be:

  • os.getenv("APPDATA") for Windows
  • os.path.expanduser("~") for Linux (and Mac?)

But as PEP 20 state "Simple is better than complex.", so not care about os and always use os.path.expanduser("~"). I must admit I don’t really like it, but I already have a lot of ".foo" folders on "C:\Users\Zykino" so it seems common to not care about standard Windows path.

I think I can implement that, but what do you think about that? Do we go specific or generic?

After asking #python-fr on Freenode’s IRC we got to the conclusion that no lib appears to exist in pypi. Also the right thing to do for each platform seems to be: * `os.getenv("APPDATA")` for Windows * `os.path.expanduser("~")` for Linux (and Mac?) But as PEP 20 state "Simple is better than complex.", so not care about os and always use `os.path.expanduser("~")`. I must admit I don’t really like it, but I already have a lot of ".foo" folders on "C:\Users\Zykino" so it seems common to not care about standard Windows path. I think I can implement that, but what do you think about that? Do we go specific or generic?
Poster
Owner

Thank you a lot for the research!

I think we may do something more generic: by default, we get the usual file directly in the root directory where prismedia is launched.

Thus we search for

  • youtube and peertube credentials
  • prismedia.txt as default file (to avoid config.txt that may be used for any other usage, as you stated ll your files are in your user directory :-D )

Both in the directory where prismedia is launched (should be relatively easy as it's already done for credentials)

And we add an option to specify a config directory, so the user is totally free to choose.

Something like prismedia --config C:\User\Prismedia or prismedia --config /etc/prismedia

As it works for video files already on multi-oses, I a pretty confident we may be able to do that for a config directory too.

When a user specify the --config directory:

  1. we search for files inside (credentials, prismedia.txt)
  2. if not found, then search in the root directory where prismedia is launched
  3. if not found, ignore (for prismedia.txt) and ask (for credentials)

Like this it should be very similar to the way enhanced NFO works, so easier to understand.

Do you think it could be relevant, if you still want to work on the feature?

Thanks!

Thank you a lot for the research! I think we may do something more generic: by default, we get the usual file directly in the root directory where prismedia is launched. Thus we search for * youtube and peertube credentials * prismedia.txt as default file (to avoid config.txt that may be used for any other usage, as you stated ll your files are in your user directory :-D ) Both in the directory where prismedia is launched (should be relatively easy as it's already done for credentials) And we add an option to specify a config directory, so the user is totally free to choose. Something like `prismedia --config C:\User\Prismedia` or `prismedia --config /etc/prismedia` As it works for video files already on multi-oses, I a pretty confident we may be able to do that for a config directory too. When a user specify the --config directory: 1. we search for files inside (credentials, prismedia.txt) 2. if not found, then search in the root directory where prismedia is launched 3. if not found, ignore (for prismedia.txt) and ask (for credentials) Like this it should be very similar to the way enhanced NFO works, so easier to understand. Do you think it could be relevant, if you still want to work on the feature? Thanks!
LecygneNoir added the
enhancement
label 3 years ago
Zykino commented 3 years ago
Poster

Not sure the --config option is needed and it’s true that we already ask the users to modify the credentials files.

Maybe putting the files you talked about in a "config" folder could be enough. If the user want another folder he can move the folder’s content, and replace it with a symbolic link.
But for config file I think having a "well known" place to look for is best.

Not sure the `--config` option is needed and it’s true that we already ask the users to modify the credentials files. Maybe putting the files you talked about in a "config" folder could be enough. If the user want another folder he can move the folder’s content, and replace it with a symbolic link. But for config file I think having a "well known" place to look for is best.
Poster
Owner

As we have to be Windows and Linux/MACOs compliant, it seems hard to choose a convenient folder usable for both, except the root directory where prismedia is launched :-/

Does symbolic link exists in windows?

My guess is to search in the local directory, as you point it it should already have credentials inside, and add a --config option as it's quite usual in command line to override the configuration file.

After reflexion, it seems complicated and it overrides the NFO system with --NFO 🤔

Perhaps the key point here is in fact to add options to specify the credentials directory instead of a "config" file that is already covered by NFO?

I see 2 advantages:

  • if there is an option, it would be possible to specify credentials path directly in NFO
  • Consequently, it'll be possible to specify differents credentials for differents video directly in NFO, which could be really useful in the future

Something like credentials-dir or peertube-creds/youtube-creds?

What do you think about this idea?

As we have to be Windows and Linux/MACOs compliant, it seems hard to choose a convenient folder usable for both, except the root directory where prismedia is launched :-/ Does symbolic link exists in windows? My guess is to search in the local directory, as you point it it should already have credentials inside, and add a `--config` option as it's quite usual in command line to override the configuration file. After reflexion, it seems complicated and it overrides the NFO system with `--NFO` 🤔 Perhaps the key point here is in fact to add options to specify the credentials directory instead of a "config" file that is already covered by NFO? I see 2 advantages: * if there is an option, it would be possible to specify credentials path directly in NFO * Consequently, it'll be possible to specify differents credentials for differents video directly in NFO, which could be really useful in the future Something like `credentials-dir` or `peertube-creds`/`youtube-creds`? What do you think about this idea?
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.