Giter VIP home page Giter VIP logo

hltv's People

Contributors

azhrak avatar breiby avatar chuli2k avatar clappis avatar danilofuchs avatar dbalders avatar deltara avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar drachenfalke12 avatar gigobyte avatar helpi90 avatar honjes avatar juhonieminen avatar kairichard avatar lactuk avatar mastef avatar mikkeldamm avatar mmarfat avatar monsieurbibo avatar morb0 avatar redzumi avatar renovate-bot avatar renovate[bot] avatar revilum avatar samuron avatar strid3r2442 avatar throwsexception avatar trevorblades avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hltv's Issues

connectToScoreboard never returns, the promise stays in "pending"

console.log(HLTV.default.connectToScorebot( {id: 2314408, onScoreboardUpdate: (data) => {
    console.log(data, 'Flag 1')
}}) )

This returns = Promise { pending }

I wasn't getting this the other day, it seems like scorebot isn't getting any data to send to me. If I am missing something please lmk

teams - fetching wrong name

Hi, i don't know, but something got changed in the api, cant get a proper team name, it happens with all the teams. You can see even through postman, something is not right. In name - it shows ENCEmousesports, when it should display hellraisers
preview

Add 'date' for 'getResults.ts'

I dont use the database for grabbing. I get the data from the saved page cache.

Can you help me get the date for 'getResults.ts'? pls

Hosting Project - Methods return empty data

I made a quick project for school using this awesome package... it was working fine on my local machine... my GetMatches() and GetResults() were returning me the correct data and everything was fine... The only weird(ish) thing I did was call these methods from my NodeJS server and then from there send it to my front end. My front end was getting the data perfectly etc.... I set up a droplet on Digital ocean, pushed my project and got it up and running. Now whenever I try to get the data my Getmatches() and GetResults() return an empty array []. Any idea what this could be?

Update dependencies

Currently some of the dependencies are outdated, they need to be updated.
(Also make sure the project builds by running the build command)

Match score

How i cant get match score when match end?

Maybe some changes on HLTV?

Since today I got this messages. I try to fetch details from this game https://www.hltv.org/matches/2326680/w7m-vs-furia-inagame-aorus-league-2018-season-3-brazil

getMatch.js

(node:16311) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:16311) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:16311) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
    at /home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getMatch.js:120:97
    at Array.map (<anonymous>)
    at Object.<anonymous> (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getMatch.js:112:87)
    at step (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getMatch.js:32:23)
    at Object.next (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getMatch.js:13:53)
    at fulfilled (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getMatch.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:16311) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)

getTeam.js

(node:30319) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 5)
(node:30319) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'split' of undefined
    at getPlayerId (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:65:48)
    at /home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:68:29
    at Array.map (<anonymous>)
    at Object.<anonymous> (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:66:122)
    at step (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:32:23)
    at Object.next (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:13:53)
    at fulfilled (/home/scidev2/Bots/hltv-scorebot/node_modules/hltv/lib/endpoints/getTeam.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:30319) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 6)

Teams Icons

This module does not receive command icons?

Error hltv.getMatches

Hello, when i updated module to 2.7.3, ive go error like this.
screenshot_1
How i can fix this? Can you help please?
This is some code:

#>function checkLive444(){
HLTV.getMatches().then((res) => {
for(var i in res)
{
var e1 = res[i].date;
var e2 = String(e1);
var event_date = e2.slice(0, -3);
if(res[i].live){
requestify.post('http://localhost/checkLive823677812aw', {match_id: res[i].id}).then(function (response) {
if(JSON.parse(response.body).status == 1){
console.log("Status live");
HLTV.getMatch({id: res[i].id}).then(res2 => {
var streams = res2.streams[0].link;
var team1_id = res2.team1Id;
var team2_id = res2.team2Id;
if(streams == 'undefined' || streams == '' || streams == ' '){streams = 'no stream';}
requestify.post('http://localhost/updateStream823677812aw', {
stream: streams,
match_id: res[i].id,
team1_id: team1_id,
team2_id: team2_id
})
.then(function (response) {
startFollow(res[i].id);
if(JSON.parse(response.body).status == 'false'){}
if(JSON.parse(response.body).status == 'true'){console.log("Stream added live");}
}, function (err) {
console.tag('Tournament').log(err);
});
});
}
}, function (err) {});
}
if(event_date == 'undefi'){}else{
if(timeDifference(event_date) == 1){
requestify.post('http://localhost/checkLive823677812aw', {match_id: res[i].id}).then(function (response) {
if(JSON.parse(response.body).status == 1){
console.log("Status live");
HLTV.getMatch({id: res[i].id}).then(res2 => {
var streams = res2.streams[0].link;
var team1_id = res2.team1Id;
var team2_id = res2.team2Id;
if(streams == 'undefined' || streams == '' || streams == ' '){streams = 'no stream';}
requestify.post('http://localhost/updateStream823677812aw', {
stream: streams,
match_id: res[i].id,
team1_id: team1_id,
team2_id: team2_id
})
.then(function (response) {
startFollow(res[i].id);
if(JSON.parse(response.body).status == 'false'){}
if(JSON.parse(response.body).status == 'true'){console.log("Stream added live");}
}, function (err) {
console.tag('Tournament').log(err);
});
});
}
}, function (err) {});
}
}
}
});
}

Match don't have additionalInfo

This match does not have any additionalInfo - https://www.hltv.org/matches/2312432/infused-vs-excel-gfinity-elite-series

But modul try get additionalInfo and we get errors:
(node:11272) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. (node:11272) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 2): TypeError: Cannot read property 'split' of undefined

Status Code: 404

Greetings! Used your development, everything worked perfectly! But recently I began to notice that instead of matches began to come an empty array. I decided to check. I sent a request on the link https://www.hltv.org/matches with the REQUEST module. The status code is 404, but the content of the page is successfully taken. Perhaps the administration of the project hltv.org made such a "bluff" to the parsers stopped working. I ask for help!

Convert response to JSON

Hello. I want to convert response to JSON - comfortable for http server in NodeJS. How can I do it ?

Parsing error

Sometimes when parsing I get an error that can happen 1000 times (in this case 1373 times): (node:22516) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1373): TypeError: Cannot read property 'split' of undefined

[bug] - getTeam from example - TypeError: Cannot read property 'split' of undefined

HLTV.getTeam({id: 6137}).then(res => {
    console.log(res);
})
(node:25940) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'split' of undefined
(node:25940) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Live FullMatch teams names

To get teams names you use - $('div.teamName')
But on this page with LIVE match 4 div with class teamName:
0:div.teamName 1:div.teamName 2:div.nameCell.teamName 3:div.nameCell.teamName
Last 2 on scorboard.

To get 1 team name you use: $('div.teamName').first() and this work
But for 2 team name you use $('div.teamName').last() and we get 3:div.nameCell.teamName not 1:div.teamName

Maybe worth using: $('div.teamName').eq(0) and $('div.teamName').eq(1)

Improve createInstance

Improve createInstance by allowing an additional object to be passed through to the fetch instance to support custom http headers, http agent and query string parameters.

I'm not up-to-scratch with my typescript - if we add in a fetchOptions object to the base HLTVConfig

export default interface HLTVConfig {
    hltvUrl?: string
    hltvStaticUrl?: string
    fetchOptions?: object
}

and then handle that inside mappers/fetchPage

export const fetchPage = async (url: string) => cheerio.load(await fetch(url, fetchOptions).then((res: any) => res.text()))

I think we're in business.

fetchOptions can be an empty object. Then we can pass through headers like user-agent, host, and referrer or a custom https agent.


isomorphic-fetch uses node-fetch https://www.npmjs.com/package/node-fetch

Looking at the docs here: https://www.npmjs.com/package/node-fetch#api

Options

{
    // These properties are part of the Fetch Standard
    method: 'GET',
    headers: {},        // request headers. format is the identical to that accepted by the Headers constructor (see below)
    body: null,         // request body. can be null, a string, a Buffer, a Blob, or a Node.js Readable stream
    redirect: 'follow', // set to `manual` to extract redirect headers, `error` to reject redirect
 
    // The following properties are node-fetch extensions
    follow: 20,         // maximum redirect count. 0 to not follow redirect
    timeout: 0,         // req/res timeout in ms, it resets on redirect. 0 to disable (OS limit applies)
    compress: true,     // support gzip/deflate content encoding. false to disable
    size: 0,            // maximum response body size in bytes. 0 to disable
    agent: null         // http(s).Agent instance, allows custom proxy, certificate etc.
}
Default Headers

If no values are set, the following request headers will be sent automatically:

Header Value
Accept-Encoding gzip,deflate (when options.compress === true)
Accept */*
Connection close (when no options.agent is present)
Content-Length (automatically calculated, if possible)
User-Agent node-fetch/1.0 (+https://github.com/bitinn/node-fetch)

So we want to be setting User-Agent at the very least to a proper browser user agent. Being able to set agent allows us to set a proxy-pass ip and port without having to host a proxied version of hltv if we so wish to.

If you're happy with that solution I can put together a PR.

something wrong with HLTV.getPlayer

I just simply use it in this way:

HLTV.getPlayer({ id: 9216 }).then(console.log, console.log)

then get an error

TypeError: Cannot read property 'includes' of undefined
    at Object.<anonymous> (node_modules/hltv/lib/endpoints/getPlayer.js:54:41)
    at step (node_modules/hltv/lib/endpoints/getPlayer.js:32:23)
    at Object.next (node_modules/hltv/lib/endpoints/getPlayer.js:13:53)
    at fulfilled (node_modules/hltv/lib/endpoints/getPlayer.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

then I go check the related source code

shownImage = $('.containedImageFrame img').attr('src');
image = !shownImage.includes('blankplayer') ? shownImage : undefined;

it seems that shownImage may be undefined which makes this error happened

I will make a PR later to fix it, please check it out

Format in UpcomingMatch model

In UpcomingMatch model 'format' is required but some games don't have this property.
Example: {"id":2322001,"date":1524067200000,"format":"","title":"DH Marseille Group A Elimination Match","stars":0,"live":false}
Format is empty.

Can't getMatch (id 2325766)

Can't getMatch because there is one draw in head to head history and no .winner

if (team1 && team2) {
    headToHead = toArray($('.head-to-head-listing tr')).map(matchEl => ({
        date: Number(matchEl.find('.date a span').attr('data-unix')),
        winner: {
            name: matchEl.find('.winner .flag').next().text(),
            id: Number(matchEl.find('.winner .flag').next().attr('href').split('/')[2]) //Cannot read property split of undefined
        },
        event: {
            name: matchEl.find('.event a').text(),
            id: Number(matchEl.find('.event a').attr('href').split('/')[2])
        },
        map: matchEl.find('.dynamic-map-name-short').text() as MapSlug,
        result: matchEl.find('.result').text()
    }))
} 

Match id that i can't get: 2325766
Match id with draw: 2316771

'getResults' returns duplicate matches

hltv.org/results/ has a "featured results" section containing several matches. These matches are also found elsewhere on the page. The getResults method returns all matches on the page including those in the "featured results" sections so they appear twice in the array. I believe they should be removed if possible.

Feature request

Hi, Could you add feature for getMatches() and getResults() of adding team logos so that i could use it for interpolation

No stream name

When i use getMatch for started match i dont get stream names. You use in endpoints/getMatch.ts:
name: streamEl.find('.flagAlign .spoiler').text() for get stream name, but on hltv stream don't have class .spoiler. It can be fixed if use: name: streamEl.find('.flagAlign').text().

Sending the json data to client?

Hello, i was wondering how i should go about sending the data to the client so i can use it in an app, i can only log it to the console, but using postman i get nothting in the request.

Any help would be appreciated !

Team data not parsing

Sometimes the name or id of one of the teams is not parsed.
{ "id":2313372, "team1":{ "name":"Majestic Lions", "id":6576 }, "team2":{ "name":"", "id":5412 }, "event":{ "name":"PG WAY Trnava 2017", "id":null }, "format":"Best of 3", "maps":[ "ovp", "inf", "mrg" ], "stars":0, "live":true }

fix for error on empty mapstatistics

Sometimes I got this error

(node:7959) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'match' of undefined
    at Object.exports.getMapsStatistics (/home/discord/scorebottest/node_modules/hltv/lib/utils/mappers.js:118:17)
    at Object.<anonymous> (/home/discord/scorebottest/node_modules/hltv/lib/endpoints/getTeam.js:96:47)
    at step (/home/discord/scorebottest/node_modules/hltv/lib/endpoints/getTeam.js:32:23)
    at Object.next (/home/discord/scorebottest/node_modules/hltv/lib/endpoints/getTeam.js:13:53)
    at fulfilled (/home/discord/scorebottest/node_modules/hltv/lib/endpoints/getTeam.js:4:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
(node:7959) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:7959) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I have found a way to fix this

change line 96 from

mapStatistics = mappers_1.getMapsStatistics(t$(t$('.graph').get(1)).attr('data-fusionchart-config'));

into this

try {
    mapStatistics = mappers_1.getMapsStatistics(t$(t$('.graph').get(1)).attr('data-fusionchart-config'));
} catch(_c) {
    mapStatistics = [];
}

The error appears when I try to get details from team "tempo storm" (HLTV teamId: 6118) from HLTV

Stream link Undefined in getMatch method

The getMatch method are returning link undefined for all streams.

Example:

HLTV.getMatch({ id: '2319592' }).then(result => {
console.log(result);
res.status(200).json(result);
})

returns

{ team1: { name: 'Liquid', id: 5973 },
team2: { name: 'eUnited', id: 7106 },
winnerTeam: undefined,
date: 1524607200000,
format: 'Best of 1',
additionalInfo: '',
event: { name: 'ECS Season 5 North America', id: 3602 },
maps: [ { name: 'inf', result: '' } ],
players:
{ team1: [ [Object], [Object], [Object], [Object], [Object] ],
team2: [ [Object], [Object], [Object], [Object], [Object] ] },
streams: [ { name: 'FACEIT TV', link: undefined, viewers: 7800 } ],
live: true,
title: undefined,
hasScorebot: true,
highlightedPlayer: { name: 'NAF', id: 8520 },
headToHead:
[ { date: 1499814096000,
winner: [Object],
event: [Object],
map: 'cbl',
result: '16 - 7' },
{ date: 1499814096000,
winner: [Object],
event: [Object],
map: 'mrg',
result: '16 - 14' } ],
vetoes: [],
highlights: [] }

Cloudflare HLTV

Good afternoon. I ran my script, he worked for about 2 hours and I got a ip-ban on HLTV. Do you know the circumvention of this restriction? When a certain number of requests come through your API, the cloudflare automatically ban my IP

CORS error

Hello,

I just wanted to try your api, but unfortunately I got this error:
Fetch API cannot load http://www.hltv.org/matches. Redirect from 'http://www.hltv.org/matches' to 'https://www.hltv.org/matches' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

Anything what could help?
Thanks!

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.