Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetInputSourcePath #80

Closed
flossy83 opened this issue Nov 8, 2022 · 7 comments
Closed

GetInputSourcePath #80

flossy83 opened this issue Nov 8, 2022 · 7 comments
Labels
enhancement New feature or request

Comments

@flossy83
Copy link

flossy83 commented Nov 8, 2022

Could we please have a _env->AddFunction("GetInputSourcePath") so we can tell what video is playing so we can make our own per-file/folder scripting rules. i.e same as API_MSG_GET_INPUT_SOURCE_PATH but accessible inside avs script.

@CrendKing CrendKing added the enhancement New feature or request label Nov 9, 2022
@CrendKing
Copy link
Owner

CrendKing commented Nov 10, 2022

@flossy83
Copy link
Author

flossy83 commented Nov 10, 2022

Thanks a lot, much appreciated.

eg.

AvsFilterSource()

if (FindStr(AvsFilterGetSourcePath(), "Series\Comedy\(2001-2003) The Office") != 0){
    Subtitle("Now playing: The Office")
}
else if (FindStr(AvsFilterGetSourcePath(), "Series\Comedy\(2005-2007) Extras") != 0){
    Subtitle("Now playing: Extras")
}
else {
    AvsFilterDisconnect()
}

#FindStr() is case-sensitive

@Nuihc88
Copy link

Nuihc88 commented Nov 10, 2022

This is a very minor detail, but i think it would be better to have a more consistent naming scheme, like either:
AvsFilterGetSourcePath() & VpsFilterGetSourcePath
or
AvsFilterSourcePath() & VpsFilterSourcePath
Otherwise people who use both AviSynth & VapourSynth are going to be getting it wrong half the time.

@CrendKing
Copy link
Owner

Reason is, AviSynth is a function, VapourSynth is a variable. It doesn't make sense to have a verb in a variable name.

The AvsFilterSource API is slightly different, that I'm following the existing convention in the avs world (e.g. AviSource, DirectShowSource). Otherwise, I'd name it AvsFilterGetSourceClip().

@Nuihc88
Copy link

Nuihc88 commented Nov 10, 2022

Reason is, AviSynth is a function, VapourSynth is a variable. It doesn't make sense to have a verb in a variable name.

Fair enough.

The AvsFilterSource API is slightly different, that I'm following the existing convention in the avs world (e.g. AviSource, DirectShowSource). Otherwise, I'd name it AvsFilterGetSourceClip().

Not quite sure i get what you mean by existing convention here, but many AviSynth-functions i know of, have names that lack the verb entirely. (e.g. ScriptFile() VersionString() Time("%#d/%#m/%y") )

So based on the ScriptFile() example, AvsFilterSourceFile() & VpsFilterSourceFile would also be consistent with AVS convention as i understand it.

@CrendKing
Copy link
Owner

CrendKing commented Nov 11, 2022

Time("%#d/%#m/%y")

So without reading document, will user be able to tell if this sets time or gets time in specified format? Will user know VersionString() gets version or sets version with default value?

There is a good reason most coding style guides recommend having verb + subject form as function name for clarity. Like I said, the only reason AvsFilterSource was such named is because many avs functions do not have verb in their names. I have no idea why such convention was set, but I personally dislike it and consider wrong.

Since AvsFilterGetSourcePath is a new API and I believe very few people will use it, I think it's better to just do it the correct way.

@Nuihc88
Copy link

Nuihc88 commented Nov 11, 2022

So without reading document, will user be able to tell if this sets time or gets time in specified format? Will user know VersionString() gets version or sets version with default value?

I think in the context of AviSynth-scripting, the purpose of 'GetString'-type functions can be inferred, since most 'SetString'-type functions never need to be accessed from the scripting-interface, but i get why it would be bad for a project that needs to set time or spoof version info.

There is a good reason most coding style guides recommend having verb + subject form as function name for clarity. Like I said, the only reason AvsFilterSource was such named is because many avs functions do not have verb in their names. I have no idea why such convention was set, but I personally dislike it and consider wrong.

I suspect it was done in part for the sake of brevity and in part to create more of a separation between backend-code and user-side-scripting, but i get now what you mean.

Since AvsFilterGetSourcePath is a new API and I believe very few people will use it, I think it's better to just do it the correct way.

Ok, fair enough.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants