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

[AutoTimer] API param to clearUnsetValues on /edit #430

Open
wedebe opened this issue Mar 21, 2021 · 15 comments
Open

[AutoTimer] API param to clearUnsetValues on /edit #430

wedebe opened this issue Mar 21, 2021 · 15 comments

Comments

@wedebe
Copy link
Contributor

wedebe commented Mar 21, 2021

Feature request:
AutoTimers which are edited to remove all bouquets/services/include or exclude (and maybe other) attribute values, maintain the previous values unless empty params are sent, eg. bouquets=&.

It would be nice to have a param such as clearUnsetValues=true to wipe unset attributes from an autotimer.

@jbleyel
Copy link
Contributor

jbleyel commented Mar 21, 2021

Hi @wedebe , all of your 3 requests can be done very easy.

BUT !!

There are many different autotimer plugin versions out there and the API version is also different.
https://github.com/oe-alliance/enigma2-plugins/tree/master/autotimer
https://github.com/OpenPLi/enigma2-plugins/tree/master/autotimer
https://github.com/opendreambox/enigma2-plugins/tree/master/autotimer
https://github.com/oe-alliance/enigma2-plugins/tree/master/vixautotimer
ect.....

@wedebe
Copy link
Contributor Author

wedebe commented Mar 21, 2021

@jbleyel , Should I copy each issue to each of the repos?

@jbleyel
Copy link
Contributor

jbleyel commented Mar 21, 2021

You can.
Your requests are not autotimer related and will have very low prio.
I think you should create only one single issue.

Please do not count on and think about "what if not".

@jbleyel
Copy link
Contributor

jbleyel commented Mar 21, 2021

What exactly do you wanna clean with "clearUnsetValues=true"?
Can you explain the use case a little bit more?

@wedebe
Copy link
Contributor Author

wedebe commented Mar 21, 2021

AutoTimer keeps values such as offset, services, bouquets, and (most troublesome) filters title, shortdescription, description, dayofweek, !title, !shortdescription, !description, !dayofweek.

Standard html form submission omits parameters which don't have a value, however I currently have to set
offset=, services=, etc... when I submit to /edit for them to be removed from the AutoTimer's attributes.

Removing filter attributes is a pain as they each seem to need to be kept track of and sent as empty values.

Eg.
AT with filters
/edit?!title=test&dayofweek=3
subsequently changed and submitted as /edit?!title=test
will keep dayofweek=3

@wedebe
Copy link
Contributor Author

wedebe commented Mar 21, 2021

		# Excludes
		title = get("!title")
		shortdescription = get("!shortdescription")
		description = get("!description")
		dayofweek = get("!dayofweek")
# if ANY of the 4 filter parameters are found  in the form submission...
		if title or shortdescription or description or dayofweek: 
# ... ALL of the timer's existing filter attributes are brought back...
			excludes = timer.exclude
# ... unless they're overwritten by the same number or more of the parameters found in the form submission
			title = [unquote(x) for x in title] if title else excludes[0] 
			shortdescription = [unquote(x) for x in shortdescription] if shortdescription else excludes[1]
			description = [unquote(x) for x in description] if description else excludes[2]
			dayofweek = [unquote(x) for x in dayofweek] if dayofweek else excludes[3]
			while '' in title: title.remove('')
			while '' in shortdescription: shortdescription.remove('')
			while '' in description: description.remove('')
			while '' in dayofweek: dayofweek.remove('')
			timer.exclude = (title, shortdescription, description, dayofweek)

Another example would be an AutoTimer with filters title=aaa&title=bbb&title=ccc
changed by submitting /edit?title=yyy&title=zzz
now has the filters title=yyy&title=zzz&title=ccc

@jbleyel
Copy link
Contributor

jbleyel commented Mar 21, 2021

I think there is a py3 problem.

PY2:
title = req.args.get("!title")

PY3:
title = get("!title")

req.args.get("!title") can be an array
get("!title") can be only one value

This needs to be fixed in the PY3 version like so.

def getA(name, default=None):
	name = six.ensure_binary(name)
	ret = req.args.get(name)
	return [six.ensure_str(x) for x in ret] if ret else default
..
..

title = getA("title")

@jbleyel
Copy link
Contributor

jbleyel commented Mar 21, 2021

@wedebe
Copy link
Contributor Author

wedebe commented Mar 22, 2021

I'll test, thanks.

I would be concerned that without an additional param, existing api consumers might experience unexpected behaviour.

@wedebe
Copy link
Contributor Author

wedebe commented Mar 22, 2021

BTW, I've got a branch in progress at
https://github.com/wedebe/e2openplugin-OpenWebif/tree/autotimers
(There's a feature flag that'll need to be changed to enable filterEditing on PY3...)
change at.tmpl
#if $PY3 to #if False

I've been testing on OpenATV versions 6.5 and 6.4

@wedebe wedebe changed the title [AutoTimer] API param to clearUnsetValues [AutoTimer] API param to clearUnsetValues on /edit Mar 22, 2021
@jbleyel
Copy link
Contributor

jbleyel commented Mar 22, 2021

I will commit the PY3 fix if you have test it cause i'm not able to test PY3 at the moment.
The gist change will only sync the PY2 and PY3 api behavior.

@jbleyel
Copy link
Contributor

jbleyel commented Mar 22, 2021

I have made the commit because i'ts working on PY2 and should also work on PY3.

@wedebe
Copy link
Contributor Author

wedebe commented Mar 22, 2021

I think there is a py3 problem.

PY2:
title = req.args.get("!title")

PY3:
title = get("!title")

req.args.get("!title") can be an array
get("!title") can be only one value

This needs to be fixed in the PY3 version like so.

def getA(name, default=None):
	name = six.ensure_binary(name)
	ret = req.args.get(name)
	return [six.ensure_str(x) for x in ret] if ret else default
..
..

title = getA("title")

This fixes a separate problem on PY3 which was that title=foo ended up being ingested as
title=f
title=o
title=o

Unfortunately, deleting filter values still doesn't function as expected.

My apologies, this now works better than expected, but not entirely.
Now, deleting a single remaining filter, doesn't remove it from the autotimer's attributes.

@jbleyel
Copy link
Contributor

jbleyel commented Mar 22, 2021

Please provide an example.
I have test this on PY2 with OWF classic and i have no issue.

@wedebe
Copy link
Contributor Author

wedebe commented Mar 22, 2021

Sorry, I'd commented out code that sent an empty param, the filter removal now works as expected on OpenATV6.5, thanks!

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

No branches or pull requests

2 participants