Sunshine icon indicating copy to clipboard operation
Sunshine copied to clipboard

Cover Finder

Open mariotaku opened this issue 2 years ago • 22 comments

Description

This PR adds functionality to search game cover image, collected from IGDB.com.

Screenshot

image

Type of Change

  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [x] New feature (non-breaking change which adds functionality)
  • [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • [ ] My code follows the style guidelines of this project
  • [ ] I have performed a self-review of my own code
  • [ ] I have commented my code, particularly in hard-to-understand areas
  • [ ] I have added or updated the docstring/documentation-blocks for new or existing methods/components

mariotaku avatar Jun 19 '22 15:06 mariotaku

Your PR was set to master, PRs should be sent to nightly The base branch of this PR has been automatically changed to nightly, please check that there are no merge conflicts

github-actions[bot] avatar Jun 19 '22 15:06 github-actions[bot]

Flatpak will fail in the build. I have a fix, but am waiting until after I merge #204 and #214 .

ReenigneArcher avatar Jun 27 '22 16:06 ReenigneArcher

Unable to find curl on linux.

ReenigneArcher avatar Jun 27 '22 20:06 ReenigneArcher

We should probably add curl here...

https://github.com/SunshineStream/Sunshine/blob/nightly/CMakeLists.txt#L607-L608

I usually use this to get the package names: https://pkgs.org/search/?q=libcurl

ReenigneArcher avatar Jun 28 '22 03:06 ReenigneArcher

This should be good. Except for flatpak configuration because I'm not sure how to properly ship libcurl.

mariotaku avatar Jun 28 '22 05:06 mariotaku

@mariotaku Can you update your branch with latest changes from nightly? This "should" fix the flatpak build failing.

Although it won't include curl. @istori1 can probably take a look at adding curl to the flatpak.

ReenigneArcher avatar Jun 30 '22 00:06 ReenigneArcher

@mariotaku I have a question. Is the sql database (https://github.com/SunshineStream/db/blob/gh-pages/gcdb.sqlite3) used by sunshine or at all? I didn't see any reference to it, although I might have missed it.

I'm thinking it's not used currently, and just put there for a possible future scenario.

ReenigneArcher avatar Jul 05 '22 00:07 ReenigneArcher

@ReenigneArcher The repo is supposed to have actions running periodically. And the sqlite3 database is used for storing game and cover data. Later they will be extracted and converted to JSON.

mariotaku avatar Jul 05 '22 01:07 mariotaku

I haven't gotten around to activating the actions quite yet. It's on my to do list.

Okay, so you are creating the json file in the buckets after the sql database?

You can extract everything directly to json from igdb. https://github.com/twitchtv/igdb-api-python

ReenigneArcher avatar Jul 05 '22 01:07 ReenigneArcher

By downloading to database, it can fetch recently updated items only. So it will save a huge amount of time.

mariotaku avatar Jul 05 '22 01:07 mariotaku

In other words, right now this repo is doing differential updates, without fetching whole IGDB everyday.

mariotaku avatar Jul 05 '22 01:07 mariotaku

@mariotaku would you mind updating your PR branch?

ReenigneArcher avatar Jul 30 '22 20:07 ReenigneArcher

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Jul 31 '22 04:07 CLAassistant

Testing this on Windows (with Chrome) and get two errors when selecting a cover image.

image

image

ReenigneArcher avatar Aug 03 '22 22:08 ReenigneArcher

Sorry, but I can't reproduce it. Could you show the request body to this endpoint?

mariotaku avatar Aug 04 '22 01:08 mariotaku

Request Payload

{
    "key": "igdb_10032",
    "url": "https://images.igdb.com/igdb/image/upload/t_cover_big_2x/co1rg8.png"
}

Response

{
    "error": "Failed to download cover"
}

I don't know if it matters, but I am in incognito mode (I always use it for testing different builds)

ReenigneArcher avatar Aug 04 '22 02:08 ReenigneArcher

I have another problem running the portable version of this build (on my non development PC). libcurl is missing. Must not be an issue on my main laptop because it's installed somewhere on PATH.

Windows 10: image

Sunshine will not start at all.

I think adding curl here will resolve it: https://github.com/LizardByte/Sunshine/blob/b11d73599448fd4608c841811896d49c9dfa2236/.github/workflows/CI.yml#L726

package name -> mingw-w64-curl

Edit: this is also an issue on a fresh Windows 10 VM, so probably this is going to be common to all Windows 10 users.

ReenigneArcher avatar Aug 08 '22 15:08 ReenigneArcher

While on topic of curl, probably needs to be added to these other locations:

Pacakge Name Location
curl https://github.com/LizardByte/Sunshine/blob/b11d73599448fd4608c841811896d49c9dfa2236/.github/workflows/CI.yml#L440
curl https://github.com/LizardByte/Sunshine/blob/b11d73599448fd4608c841811896d49c9dfa2236/packaging/macos/Portfile#L35
curl https://github.com/LizardByte/Sunshine/blob/b11d73599448fd4608c841811896d49c9dfa2236/packaging/linux/aur/PKGBUILD#L12
mingw-w64-curl https://github.com/LizardByte/Sunshine/blob/b11d73599448fd4608c841811896d49c9dfa2236/.github/workflows/CI.yml#L726

ReenigneArcher avatar Aug 08 '22 15:08 ReenigneArcher

Still have this error with latest build: https://github.com/LizardByte/Sunshine/pull/216#issuecomment-1208271698

ReenigneArcher avatar Aug 08 '22 20:08 ReenigneArcher

Any update on this? Anything I can provide to help resolve the issues?

  • [x] Windows 10 - libcurl-4.dll missing - https://github.com/LizardByte/Sunshine/pull/216#issuecomment-1208271698
  • [x] Windows 11 and maybe others - CURLE_SSL_CACERT_BADFILE (77) error when trying to save image

ReenigneArcher avatar Oct 10 '22 18:10 ReenigneArcher

Hi. Sorry I've gotten busy these days. Is it possible to ask you to make some changes if you have clues to fix the above issues?

mariotaku avatar Oct 11 '22 13:10 mariotaku

Hi. Sorry I've gotten busy these days. Is it possible to ask you to make some changes if you have clues to fix the above issues?

I will see what I can do, as well as check with some other developers.

These are some references for the missing dll issue.

  • https://stackoverflow.com/a/29670866/11214013
  • https://stackoverflow.com/a/11545568/11214013
  • https://stackoverflow.com/a/32476811/11214013

It appears that we need to place the dll next to sunshine.exe or statically linking curl.

ReenigneArcher avatar Oct 11 '22 14:10 ReenigneArcher

Hi,

It seems there was a problem with static linking that affected libcurl. If you cherry-pick this commit, it should work ok: https://github.com/psyke83/SunshineStream/commit/92b90cd03325ae5fd07d593b3475e4e621163d8e

With the above commit:

# ldd sunshine.exe
        ntdll.dll => /c/Windows/SYSTEM32/ntdll.dll (0x7ff87ecf0000)
        KERNEL32.DLL => /c/Windows/System32/KERNEL32.DLL (0x7ff87db50000)
        KERNELBASE.dll => /c/Windows/System32/KERNELBASE.dll (0x7ff87c3f0000)
        ADVAPI32.dll => /c/Windows/System32/ADVAPI32.dll (0x7ff87e250000)
        msvcrt.dll => /c/Windows/System32/msvcrt.dll (0x7ff87da10000)
        sechost.dll => /c/Windows/System32/sechost.dll (0x7ff87dc70000)
        RPCRT4.dll => /c/Windows/System32/RPCRT4.dll (0x7ff87e050000)
        bcrypt.dll => /c/Windows/System32/bcrypt.dll (0x7ff87c6d0000)
        CRYPT32.dll => /c/Windows/System32/CRYPT32.dll (0x7ff87cbe0000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7ff87cae0000)
        ole32.dll => /c/Windows/System32/ole32.dll (0x7ff87de90000)
        d3d11.dll => /c/Windows/SYSTEM32/d3d11.dll (0x7ff878100000)
        D3DCOMPILER_47.dll => /c/Windows/SYSTEM32/D3DCOMPILER_47.dll (0x7ff878370000)
        combase.dll => /c/Windows/System32/combase.dll (0x7ff87e300000)
        dwmapi.dll => /c/Windows/SYSTEM32/dwmapi.dll (0x7ff87a0f0000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x7ff87c910000)
        win32u.dll => /c/Windows/System32/win32u.dll (0x1cb6d9e0000)
        GDI32.dll => /c/Windows/System32/GDI32.dll (0x7ff87d1c0000)
        dxgi.dll => /c/Windows/SYSTEM32/dxgi.dll (0x7ff87acb0000)
        USER32.dll => /c/Windows/System32/USER32.dll (0x7ff87eb10000)
        gdi32full.dll => /c/Windows/System32/gdi32full.dll (0x7ff87c9d0000)
        IPHLPAPI.DLL => /c/Windows/SYSTEM32/IPHLPAPI.DLL (0x7ff87b7c0000)
        msvcp_win.dll => /c/Windows/System32/msvcp_win.dll (0x7ff87c7c0000)
        CRYPTSP.dll => /c/Windows/SYSTEM32/CRYPTSP.dll (0x7ff87bda0000)
        SETUPAPI.dll => /c/Windows/System32/SETUPAPI.dll (0x7ff87e660000)
        cfgmgr32.dll => /c/Windows/System32/cfgmgr32.dll (0x7ff87c770000)
        WLDAP32.dll => /c/Windows/System32/WLDAP32.dll (0x7ff87e1e0000)
        WINMM.dll => /c/Windows/SYSTEM32/WINMM.dll (0x7ff872930000)
        WS2_32.dll => /c/Windows/System32/WS2_32.dll (0x7ff87d9a0000)
        WSOCK32.dll => /c/Windows/SYSTEM32/WSOCK32.dll (0x7ff86dc00000)
        MSWSOCK.DLL => /c/Windows/SYSTEM32/MSWSOCK.DLL (0x7ff87bb40000)

I did a quick test and the cover finder feature seems to retrieve images correctly on Windows 10.

psyke83 avatar Nov 17 '22 09:11 psyke83

@psyke83 Very awesome change!

mariotaku avatar Nov 17 '22 13:11 mariotaku

@psyke83 Thank you so much!

@mariotaku looks like a couple of failures, should be easy to resolve.

  1. clang reports an extra space
  2. docker build failing... missing a dependency per https://github.com/LizardByte/Sunshine/actions/runs/3488506314/jobs/5837582884#step:9:3163
#15 1.895 CMake Error at /usr/share/cmake-3.22/Modules/FindPkgConfig.cmake:603 (message):
#15 1.895   A required package was not found

Should just be a matter of adding the dependency here: https://github.com/mariotaku/Sunshine/blob/6806ae2335565f61b1629502d23ceed3eb2c004f/Dockerfile#L17

libcurl4-openssl-dev if I'm not mistaken.

ReenigneArcher avatar Nov 17 '22 13:11 ReenigneArcher

#0 4.498 Reading package lists...
#0 5.230 Building dependency tree...
#0 5.357 Reading state information...
#0 5.362 Package libcurl4-openssl-dev is not available, but is referred to by another package.
#0 5.362 This may mean that the package is missing, has been obsoleted, or
#0 5.362 is only available from another source
#0 5.362 However the following packages replace it:
#0 5.363   libcurl4-doc
#0 5.363 
#0 5.365 E: Version '7.68.0*' for 'libcurl4-openssl-dev' was not found

Perhaps this is just a version issue. https://packages.ubuntu.com/jammy/libcurl4-openssl-dev

Flatpak failure is likely just an intermittent failure. It happens from time to time.

ReenigneArcher avatar Nov 17 '22 16:11 ReenigneArcher

@ReenigneArcher Oh! I thought 22.04 is focal.

mariotaku avatar Nov 17 '22 16:11 mariotaku

Thanks for working on this everyone! I will test it in Windows 11 and 10 tonight. If it's all working, I'll assume we're good to merge, since it worked in Linux before.

ReenigneArcher avatar Nov 17 '22 20:11 ReenigneArcher

Unfortunately, with Windows 11 I am still not able to upload the cover.

image

I can at least start Sunshine in Windows 10 now though. I couldn't get any further than that since my test machine doesn't have a display connected. I can test Windows 10 further tomorrow.

ReenigneArcher avatar Nov 18 '22 01:11 ReenigneArcher

I saw this on Sunshine's log output:

[2022:11:18:01:51:29]: Error: Couldn't download [https://images.igdb.com/igdb/image/upload/t_cover_big_2x/co4rjc.png, code:77]

Code 77 is related to the certificate store; presumably curl is not able to find it in the expected format on a Windows system. I feel that instead of copying the certificate store, it would be better to use Windows' own internal store instead.

To that effect, changing the build system to install mingw-w64-x86_64-curl-winssl (instead of mingw-w64-x86_64-curl, as they are in conflict), it seems that it will work. I might have had the -winssl variant installed when I tested, which is why I didn't catch the problem.

psyke83 avatar Nov 18 '22 02:11 psyke83