Giter Site home page Giter Site logo

Need help with module about nvchecker HOT 7 CLOSED

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024
Need help with module

from nvchecker.

Comments (7)

lilydjwg avatar lilydjwg commented on June 2, 2024

What you pass to the json argument is a string, not a dict. Try to remove the outmost quotes and rewrite it as a proper Python dict.

from nvchecker.

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024

Should this be working?

from nvchecker.api import (
  VersionResult, Entry, AsyncCache, KeyManager,
  TemporaryError, session, GetVersionError,
)

API_URL = 'https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery'

HEADERS = {
  'Accept': 'application/json;api-version=6.1-preview.1',
  'Content-Type': 'application/json'
}

async def get_version(name: str, conf: Entry, *, cache: AsyncCache, **kwargs):
  name = conf.get('vsmarketplace') or name

  q = {
    'filters': [
      {
        'criteria': [
          {
            'filterType': 8,
            'value': 'Microsoft.VisualStudio.Code'
          },
          {
            'filterType': 10,
            'value': name
          },
          {
            'filterType': 12,
            'value': '4096'
          }
        ],
        'pageNumber': 1,
        'pageSize': 2,
        'sortBy': 0,
        'sortOrder': 0
      }
    ],
    'assetTypes': [],
    'flags': 946
  }

  res = await session.post(
    API_URL,
    headers = HEADERS,
    json = q,
  )
  j = res.json()

  version = j['results'][0]['extensions'][0]['versions'][0]['version']
  return version

It still fails with

[E 07-14 14:29:22.383 core:328] vscodeMarketplace-extension: unexpected error happened error=IndexError('list index out of range')
    Traceback (most recent call last):
      File "/nix/store/z4dr34bha47409m75c4a735vlmdd6y2p-python3.8-nvchecker-2.4.dev0/lib/python3.8/site-packages/nvchecker/util.py", line 262, in run_one
        version = await self.func(
      File "/nix/store/z4dr34bha47409m75c4a735vlmdd6y2p-python3.8-nvchecker-2.4.dev0/lib/python3.8/site-packages/nvchecker_source/vsmarketplace.py", line 55, in get_version
        version = extension[0]
    IndexError: list index out of range

from nvchecker.

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024

This is the json

{
  "results": [
    {
      "extensions": [
        {
          "publisher": {
            "publisherId": "17fd9a78-e430-4a78-add2-ade4a8830352",
            "publisherName": "ritwickdey",
            "displayName": "Ritwick Dey",
            "flags": "verified"
          },
          "extensionId": "b63c44fd-0457-4696-99e9-dbfdf70d77de",
          "extensionName": "LiveServer",
          "displayName": "Live Server",
          "flags": "validated, public",
          "lastUpdated": "2019-04-17T10:42:11.2Z",
          "publishedDate": "2017-06-27T21:14:04.557Z",
          "releaseDate": "2017-06-27T21:14:04.557Z",
          "shortDescription": "Launch a development local Server with live reload feature for static & dynamic pages",
          "versions": [
            {
              "version": "5.6.1",
              "flags": "validated",
              "lastUpdated": "2019-04-17T10:44:32.54Z",
              "files": [
                {
                  "assetType": "Microsoft.VisualStudio.Code.Manifest",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Code.Manifest"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.Changelog",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.Content.Changelog"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.Details",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.Content.Details"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Content.License",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.Content.License"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Icons.Default",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.Icons.Default"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.Icons.Small",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.Icons.Small"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.VsixManifest",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.VsixManifest"
                },
                {
                  "assetType": "Microsoft.VisualStudio.Services.VSIXPackage",
                  "source": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217/Microsoft.VisualStudio.Services.VSIXPackage"
                }
              ],
              "properties": [
                {
                  "key": "Microsoft.VisualStudio.Services.Branding.Color",
                  "value": "#41205f"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Branding.Theme",
                  "value": "dark"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Getstarted",
                  "value": "https://github.com/ritwickdey/vscode-live-server.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Support",
                  "value": "https://github.com/ritwickdey/vscode-live-server/issues"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Learn",
                  "value": "https://ritwickdey.github.io/vscode-live-server/"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.Source",
                  "value": "https://github.com/ritwickdey/vscode-live-server.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.Links.GitHub",
                  "value": "https://github.com/ritwickdey/vscode-live-server.git"
                },
                {
                  "key": "Microsoft.VisualStudio.Code.Engine",
                  "value": "^1.20.0"
                },
                {
                  "key": "Microsoft.VisualStudio.Services.GitHubFlavoredMarkdown",
                  "value": "true"
                },
                {
                  "key": "Microsoft.VisualStudio.Code.ExtensionDependencies",
                  "value": ""
                },
                {
                  "key": "Microsoft.VisualStudio.Code.ExtensionPack",
                  "value": ""
                },
                {
                  "key": "Microsoft.VisualStudio.Code.LocalizedLanguages",
                  "value": ""
                }
              ],
              "assetUri": "https://ritwickdey.gallerycdn.vsassets.io/extensions/ritwickdey/liveserver/5.6.1/1555497731217",
              "fallbackAssetUri": "https://ritwickdey.gallery.vsassets.io/_apis/public/gallery/publisher/ritwickdey/extension/LiveServer/5.6.1/assetbyname"
            }
          ],
          "statistics": [
            {
              "statisticName": "install",
              "value": 13229510
            },
            {
              "statisticName": "averagerating",
              "value": 4.429936408996582
            },
            {
              "statisticName": "ratingcount",
              "value": 314
            },
            {
              "statisticName": "trendingdaily",
              "value": 0.005847833767192669
            },
            {
              "statisticName": "trendingmonthly",
              "value": 5.176912818047757
            },
            {
              "statisticName": "trendingweekly",
              "value": 1.041942793232796
            },
            {
              "statisticName": "updateCount",
              "value": 3277467
            },
            {
              "statisticName": "weightedRating",
              "value": 4.4291113571543805
            },
            {
              "statisticName": "downloadCount",
              "value": 51887
            }
          ],
          "deploymentType": 0
        }
      ],
      "pagingToken": null,
      "resultMetadata": [
        {
          "metadataType": "ResultCount",
          "metadataItems": [
            {
              "name": "TotalCount",
              "count": 1
            }
          ]
        },
        {
          "metadataType": "Categories",
          "metadataItems": [
            {
              "name": "Other",
              "count": 1
            }
          ]
        }
      ]
    }
  ]
}

from nvchecker.

lilydjwg avatar lilydjwg commented on June 2, 2024

The latest code works for me. The code in your traceback is different than the code you pasted. Check if the correct code file is loaded?

from nvchecker.

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024

Line count is slightly off because I didn't include the MIT License header in the code I pasted. Same code and traceback though.

from nvchecker.

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024

Would you mind testing this PR?

from nvchecker.

Th3Whit3Wolf avatar Th3Whit3Wolf commented on June 2, 2024

Closed with 195

from nvchecker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.