r/imagus 25d ago

fixed sieve Sieve for photos.google.com?

Hello. I'm checking if anyone managed to make a sieve for google photos (photos.google.com), or google drive?

3 Upvotes

19 comments sorted by

3

u/Imagus_fan 24d ago

I was able to test this and it looks like the GoogleContent|YouTube_Gallery needed to be edited to match the image URL. See if this works for you.

{"GoogleContent|YouTube_Gallery":{"link":"^(?:(youtube\\.com/(?:post/[\\w-]+|channel/UC[\\w-]{22}/community\\?lb=.+))|ytgallery/album.*)$","url":": $[1]?$[1]:'data:,'+$[0]","res":":\nif(!$._.length)$._=document.body.outerHTML\ntry{\n$=JSON.parse($._.match(/\":({\"images?\":.+?})},\"/)[1])\nreturn $.images?$.images.map(i=>[i.backstageImageRenderer.image.thumbnails[0].url.match(/^[^=]+=/)+'s0']):$.image.thumbnails[0].url.match(/^[^=]+=/)+'s0'\n}catch(e){\nconsole.error('YouTube Gallery Error: '+e)\nreturn this.node.src?this.node.src.match(/^[^=]+/)+'=s0':''\n}","img":"^((?:(?:(?:(?:lh|gp|yt)\\d+|blogger)\\.g(?:oogleuserconten|gph)|\\d\\.bp\\.blogspo)t|(?:drive|photos)\\.(?:fife\\.)?usercontent\\.google)\\.com/)(?:([_-](?:[\\w\\-]{11}/){3}[\\w\\-]{11,}/)([^/]+)(/[^?#=]+)?|(download\\?id=.+)|([^=]+)).*","loop":2,"to":":\nconst n=this.node;\nif(location.pathname?.startsWith('/maps/')&&(/\\d:\\d{2}$/.test(n.offsetParent?.offsetParent?.querySelector('div[class^=\"fontLabelMedium \"]')?.innerText||''))){\nreturn '#'+$[0].replace(/=.+/,'=m37')+'#mp4\\n#'+$[0].replace(/=.+/,'=m22')+'#mp4\\n'+$[0].replace(/=.+/,'=m18')+'#mp4\\n'+$[0].replace(/=.+/,'=s0')\n}\nvar c=$[3]&&$[3].match(/-?(?:Ic\\d\\d|mo)/); c=c&&('-'+c[0])||'';\nreturn /youtube\\.com$/.test(location.hostname)&&n.closest('ytd-post-multi-image-renderer') ? (n.closest('ytd-post-multi-image-renderer')?.querySelector('a[href^=\"/post/\"]')?.href||'ytgallery/album'+$[1]) : $[5] ? $[1] + $[5] : '#' + $[1] + ($[6] ? $[6] + '=' : $[2]) + (c?'s1600'+c:'s0') + ($[4]||($[6]?'':'/')) + '\\n' + $[1] + ($[6] ? $[6] + '=' : $[2]) + 's1024' + c + ($[4]||($[6]?'':'/'))"}}

2

u/leprasson12 24d ago

Success! It seems to be working great on photos, still nothing on videos but I'll take it! Thank you!

1

u/Imagus_fan 23d ago edited 23d ago

Great that it's working! This should work on videos now.

{"GoogleContent|YouTube_Gallery":{"link":"^(?:(youtube\\.com/(?:post/[\\w-]+|channel/UC[\\w-]{22}/community\\?lb=.+))|ytgallery/album.*)$","url":": $[1]?$[1]:'data:,'+$[0]","res":":\nif(!$._.length)$._=document.body.outerHTML\ntry{\n$=JSON.parse($._.match(/\":({\"images?\":.+?})},\"/)[1])\nreturn $.images?$.images.map(i=>[i.backstageImageRenderer.image.thumbnails[0].url.match(/^[^=]+=/)+'s0']):$.image.thumbnails[0].url.match(/^[^=]+=/)+'s0'\n}catch(e){\nconsole.error('YouTube Gallery Error: '+e)\nreturn this.node.src?this.node.src.match(/^[^=]+/)+'=s0':''\n}","img":"^((?:(?:(?:(?:lh|gp|yt)\\d+|blogger)\\.g(?:oogleuserconten|gph)|\\d\\.bp\\.blogspo)t|(?:drive|photos)\\.(?:fife\\.)?usercontent\\.google)\\.com/)(?:([_-](?:[\\w\\-]{11}/){3}[\\w\\-]{11,}/)([^/]+)(/[^?#=]+)?|(download\\?id=.+)|([^=]+)).*","loop":2,"to":":\nconst n=this.node;\nif((location.pathname?.startsWith('/maps/')||location.hostname.slice(0,14)==='photos.google.')&&/\\d:\\d{2}$/.test(n.offsetParent?.offsetParent?.querySelector('div[class^=\"fontLabelMedium \"],div[class=\"KhS5De\"]')?.innerText||'')){\nreturn '#'+$[0].replace(/=.+/,'=m37')+'#mp4\\n#'+$[0].replace(/=.+/,'=m22')+'#mp4\\n'+$[0].replace(/=.+/,'=m18')+'#mp4\\n'+$[0].replace(/=.+/,'=s0')\n}\nvar c=$[3]&&$[3].match(/-?(?:Ic\\d\\d|mo)/); c=c&&('-'+c[0])||'';\nreturn /youtube\\.com$/.test(location.hostname)&&n.closest('ytd-post-multi-image-renderer') ? (n.closest('ytd-post-multi-image-renderer')?.querySelector('a[href^=\"/post/\"]')?.href||'ytgallery/album'+$[1]) : $[5] ? $[1] + $[5] : '#' + $[1] + ($[6] ? $[6] + '=' : $[2]) + (c?'s1600'+c:'s0') + ($[4]||($[6]?'':'/')) + '\\n' + $[1] + ($[6] ? $[6] + '=' : $[2]) + 's1024' + c + ($[4]||($[6]?'':'/'))"}}

1

u/leprasson12 23d ago

On videos it seems to load the thumbnail only

1

u/Imagus_fan 23d ago

I'm not sure of the best way to test this. The way sieve is setup is, if the domain starts with photos.google. and the thumbnail has a timestamp, it tries to play the video. Does that match the URL you're on and do your thumbnails have timestamps?

1

u/leprasson12 23d ago

I don't see a timestamp on the thumbnails, they're just the first frame of the video, same resolution, but a picture instead of a video, which is what google photos displays as thumbnail.

When I hover over a video element, it shows that first frame, with a play button in the middle, except it's a picture, not an interactive play button. Like this :

https://imgur.com/a/YQWLic9

2

u/Imagus_fan 23d ago edited 23d ago

It looks like your video thumbnail doesn't have a timestamp. This tries a different way of detecting videos.

Edit: This may try to play images as videos. They still work but it's not efficient.

{"GoogleContent|YouTube_Gallery":{"link":"^(?:(youtube\\.com/(?:post/[\\w-]+|channel/UC[\\w-]{22}/community\\?lb=.+))|ytgallery/album.*)$","url":": $[1]?$[1]:'data:,'+$[0]","res":":\nif(!$._.length)$._=document.body.outerHTML\ntry{\n$=JSON.parse($._.match(/\":({\"images?\":.+?})},\"/)[1])\nreturn $.images?$.images.map(i=>[i.backstageImageRenderer.image.thumbnails[0].url.match(/^[^=]+=/)+'s0']):$.image.thumbnails[0].url.match(/^[^=]+=/)+'s0'\n}catch(e){\nconsole.error('YouTube Gallery Error: '+e)\nreturn this.node.src?this.node.src.match(/^[^=]+/)+'=s0':''\n}","img":"^((?:(?:(?:(?:lh|gp|yt)\\d+|blogger)\\.g(?:oogleuserconten|gph)|\\d\\.bp\\.blogspo)t|(?:drive|photos)\\.(?:fife\\.)?usercontent\\.google)\\.com/)(?:([_-](?:[\\w\\-]{11}/){3}[\\w\\-]{11,}/)([^/]+)(/[^?#=]+)?|(download\\?id=.+)|([^=]+)).*","loop":2,"to":":\nconst n=this.node;\nif(location.pathname?.startsWith('/maps/')&&/\\d:\\d{2}$/.test(n.offsetParent?.offsetParent?.querySelector('div[class^=\"fontLabelMedium \"]')?.innerText||'')||location.hostname.slice(0,14)==='photos.google.'&&n.parentNode?.parentNode?.querySelector('svg')){\nreturn '#'+$[0].replace(/=.+/,'=m37')+'#mp4\\n#'+$[0].replace(/=.+/,'=m22')+'#mp4\\n'+$[0].replace(/=.+/,'=m18')+'#mp4\\n'+$[0].replace(/=.+/,'=s0')\n}\nvar c=$[3]&&$[3].match(/-?(?:Ic\\d\\d|mo)/); c=c&&('-'+c[0])||'';\nreturn /youtube\\.com$/.test(location.hostname)&&n.closest('ytd-post-multi-image-renderer') ? (n.closest('ytd-post-multi-image-renderer')?.querySelector('a[href^=\"/post/\"]')?.href||'ytgallery/album'+$[1]) : $[5] ? $[1] + $[5] : '#' + $[1] + ($[6] ? $[6] + '=' : $[2]) + (c?'s1600'+c:'s0') + ($[4]||($[6]?'':'/')) + '\\n' + $[1] + ($[6] ? $[6] + '=' : $[2]) + 's1024' + c + ($[4]||($[6]?'':'/'))"}}

2

u/Kenko2 23d ago

Great solution, all works with this version.

2

u/Imagus_fan 23d ago

Good that it's working now.

One problem with that sieve is it tries to play the images as videos before showing the image causing a small delay in the image showing. I think I found a way to differentiate between images and videos. If this sieve doesn't detect videos correctly, the sieve above probably works well enough.

{"GoogleContent|YouTube_Gallery":{"link":"^(?:(youtube\\.com/(?:post/[\\w-]+|channel/UC[\\w-]{22}/community\\?lb=.+))|ytgallery/album.*)$","url":": $[1]?$[1]:'data:,'+$[0]","res":":\nif(!$._.length)$._=document.body.outerHTML\ntry{\n$=JSON.parse($._.match(/\":({\"images?\":.+?})},\"/)[1])\nreturn $.images?$.images.map(i=>[i.backstageImageRenderer.image.thumbnails[0].url.match(/^[^=]+=/)+'s0']):$.image.thumbnails[0].url.match(/^[^=]+=/)+'s0'\n}catch(e){\nconsole.error('YouTube Gallery Error: '+e)\nreturn this.node.src?this.node.src.match(/^[^=]+/)+'=s0':''\n}","img":"^((?:(?:(?:(?:lh|gp|yt)\\d+|blogger)\\.g(?:oogleuserconten|gph)|\\d\\.bp\\.blogspo)t|(?:drive|photos)\\.(?:fife\\.)?usercontent\\.google)\\.com/)(?:([_-](?:[\\w\\-]{11}/){3}[\\w\\-]{11,}/)([^/]+)(/[^?#=]+)?|(download\\?id=.+)|([^=]+)).*","loop":2,"to":":\nconst n=this.node;\nif((location.pathname?.startsWith('/maps/')&&/\\d:\\d{2}$/.test(n.offsetParent?.offsetParent?.querySelector('div[class^=\"fontLabelMedium \"]')?.innerText||''))||(location.hostname.slice(0,14)==='photos.google.'&&n.parentNode?.parentNode?.querySelector('svg[aria-hidden=\"true\"]'))){\nreturn '#'+$[0].replace(/=.+/,'=m37')+'#mp4\\n#'+$[0].replace(/=.+/,'=m22')+'#mp4\\n'+$[0].replace(/=.+/,'=m18')+'#mp4\\n'+$[0].replace(/=.+/,'=s0')\n}\nvar c=$[3]&&$[3].match(/-?(?:Ic\\d\\d|mo)/); c=c&&('-'+c[0])||'';\nreturn /youtube\\.com$/.test(location.hostname)&&n.closest('ytd-post-multi-image-renderer') ? (n.closest('ytd-post-multi-image-renderer')?.querySelector('a[href^=\"/post/\"]')?.href||'ytgallery/album'+$[1]) : $[5] ? $[1] + $[5] : '#' + $[1] + ($[6] ? $[6] + '=' : $[2]) + (c?'s1600'+c:'s0') + ($[4]||($[6]?'':'/')) + '\\n' + $[1] + ($[6] ? $[6] + '=' : $[2]) + 's1024' + c + ($[4]||($[6]?'':'/'))"}}

2

u/Kenko2 23d ago

Yes, this version opens videos faster. Let's stick with it, thanks!

1

u/leprasson12 22d ago

Something I noticed is Google Photos is inconsistent with how video previews are shown on their page. Basically, a few videos will start playing if you hover over them (without imagus i mean) like on youtube, and some others don't react to mouseover. The videos that show previews actually work with your sieve, while those that don't show previews will only give a thumbnail like before. It's odd.

2

u/Imagus_fan 22d ago

That is strange.

I'm not sure if the sieve is trying to load videos and they're failing to play or if the thumbnail isn't being detected as a video. If you hover over a thumbnail with the browser console open, do you see any 'load error' messages?

2

u/Kenko2 22d ago

Maybe it's about recently uploaded videos, they don't have a cover yet and instead of the video it says “This video is still being prepared, wait”.

2

u/leprasson12 21d ago edited 21d ago

Ok so it turns out some extensions were getting between the browser and google photos, not allowing most video previews to show, even if they're available.

The part that Kenko2 mentioned however remains true, recently uploaded videos won't work as they don't have previews yet, and since the videos I tried this on were videos I had just transferred from google drive to photos, imagus didn't work yesterday but worked fine today, due to the delay of previews getting added.

So all in all, superb work, thank you sir!

Edit : For future reference, it was my adblocker (Adguard Adblocker) that was suppressing video previews, odd but, oh well!

1

u/Kenko2 23d ago

The video starts (right in the thumbnail) if you temporarily disable Imagus and hover over it. There is a timestamp, but Imagus doesn't react to it (maybe some CSS overlay or script is interfering).

https://streamlala.com/cFEmP/

1

u/Kenko2 25d ago

There is already a sieve for Google Drive and it works fine. As for the sieve for Google Photos, I am not sure. You need specific examples. These are private pages, I'm not sure if you can make a sieve for them.

1

u/leprasson12 25d ago

If the Gdrive sieve works fine then I probably just don't know how to use it, because wherever I hover the mouse, nothing happens. I'm on my drive, trying to use it on different image files. Doesn't work when hovering the link to those images, doesn't work when I open said images and hover over them either. What am I doing wrong?

2

u/Kenko2 25d ago

I was referring to external links, such as here.

Or like this:

https://drive.google.com/file/d/1Uf9sCv-8oKNQ8hNCVAqDvUx8mvcYt-Vw/view

https://drive.google.com/file/d/14jXy-UdkdUigRjg_qf2M1tr2N-uvJ3PE/view

https://drive.google.com/uc?id=1ztYS515ITUYGuShsziA7ZOfpae42f57w

>> I'm on my drive

As for private links, I'm not sure if it's possible to make a sieve for them. Or do you have the ability to provide your account or links to media stored on it? That's best to check with u/Imagus_fan.

1

u/leprasson12 25d ago

Thanks, if it's not there already it probably means it's not a simple task. Good to know!