thp / urlwatch

Watch (parts of) webpages and get notified when something changes via e-mail, on your phone or via other means. Highly configurable.
https://thp.io/2008/urlwatch/
Other
2.83k stars 350 forks source link

Change content of 'reported details' #456

Closed plt-prx closed 4 years ago

plt-prx commented 4 years ago

Hi,

first of all thanks for this great tool! Sorry if this should be a too simple question; I am looking for a way to change the content of the 'details'. Through the config file I can only decide between details=true and details=false. What I try to achieve is to get rid of the timecode lines:

CHANGED: TIME (https://www.timeanddate.com/worldclock/germany/berlin)
--- @   Thu, 27 Feb 2020 14:12:02 +0100
+++ @   Thu, 27 Feb 2020 15:19:05 +0100
@@ -1 +1 @@
-14:12:02
+15:19:03

So it looks like this:

CHANGED: TIME (https://www.timeanddate.com/worldclock/germany/berlin) -14:12:02 +15:19:03

I tried tampering with the reporters.py file but failed (mostly due not being able to read/write python.

Thanks!

plt-prx commented 4 years ago

Ok, I managed to get this:

CHANGED: TIME (https://www.timeanddate.com/worldclock/germany/berlin)
---
+++
@@ -1 +1 @@
-16:53:26
+16:53:38

by deleting the '@', '@', timestamp_old, timestamp_new from:

return ''.join(difflib.unified_diff([l + '\n' for l in job_state.old_data.splitlines()],
                                            [l + '\n' for l in job_state.new_data.splitlines()],
                                            '@', '@', timestamp_old, timestamp_new))

Could somebody help me finding the code part of the reporters.py which is responsible for this part of the output:

---
+++
@@ -1 +1 @@
thp commented 4 years ago

Git master (not yet in any release) now supports a diff_filter which you can apply.

Two examples are documented: https://urlwatch.readthedocs.io/en/latest/advanced.html#only-show-added-or-removed-lines https://urlwatch.readthedocs.io/en/latest/advanced.html#pass-diff-output-to-a-custom-script

This should give you the flexibility to filter - if needed with an external shellpipe filter - the diff contents to the right format that you want to have.

adriangalilea commented 2 months ago

@thp it does not work for me.

I see no indication of the shellpipe doing anything. (Mac) Same exact output weather I have the shellpipe or not.

Why not just allow for specifying the report template in the config?

thp commented 2 months ago

@thp it does not work for me.

I see no indication of the shellpipe doing anything. (Mac) Same exact output weather I have the shellpipe or not.

Why not just allow for specifying the report template in the config?

Can you open a new issue for this? Also, can you specify a bit more directly what are you trying to achieve, how you have urlwatch configured and what you would expect the output to be and what the actual output is? Also make sure you're using the latest version of urlwatch, and confirm that it contains this change.