From 004463d3275fe8e4f271e29fa91374e81777f272 Mon Sep 17 00:00:00 2001 From: Claromes Date: Wed, 31 May 2023 09:30:04 -0300 Subject: [PATCH 01/12] update readme and docs --- README.md | 8 +++++++- docs/index.md | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 96f5714..cb6daec 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ Python client library to easily integrate with [FIVB VIS Web Service](https://ww Responses are formatted using JSON. +**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB).** + +## Requirements + +- Python 3.8+ + ## Installation ```shell @@ -145,7 +151,7 @@ print(vm.match(9211)) ## [Documentation](https://claromes.github.io/fivbvis) -## Requests Available +## Available Requests - Article - VolleyMatch diff --git a/docs/index.md b/docs/index.md index 2c5f7fd..c9aa2b8 100644 --- a/docs/index.md +++ b/docs/index.md @@ -6,10 +6,16 @@ Python client library to easily integrate with [FIVB VIS Web Service](https://ww Responses are formatted using JSON. +**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB).** +
# Docs +## Requirements + +- Python 3.8+ + ## Installation ```shell @@ -293,3 +299,7 @@ Get a list of volleyball matches.
[VIS Web Service Requests full list](https://www.fivb.org/VisSDK/VisWebService/RequestList.html) + +## Author + +[claromes](https://claromes.gitlab.io/) \ No newline at end of file From 917e7ab54f390818e9d94f1566d7504bd2a05649 Mon Sep 17 00:00:00 2001 From: Claromes Date: Thu, 1 Jun 2023 07:40:11 -0300 Subject: [PATCH 02/12] update docs --- docs/index.md | 8 -------- 1 file changed, 8 deletions(-) diff --git a/docs/index.md b/docs/index.md index c9aa2b8..e1b4723 100644 --- a/docs/index.md +++ b/docs/index.md @@ -22,8 +22,6 @@ Responses are formatted using JSON. pip3 install fivbvis ``` -
- ## Usage ```python from fivbvis import VolleyMatch @@ -155,8 +153,6 @@ print(vm.match(9211)) } ``` -
- ## Requests ### Article @@ -238,8 +234,6 @@ Get a list of article. ### VolleyLive ---- -
- ### VolleyMatch ---- @@ -296,8 +290,6 @@ Get a list of volleyball matches. ### VolleyTransfer ---- -
- [VIS Web Service Requests full list](https://www.fivb.org/VisSDK/VisWebService/RequestList.html) ## Author From 19ff5b1d99f1fdc16d10e9548e03d23e2efbff4f Mon Sep 17 00:00:00 2001 From: Claromes Date: Sun, 14 Jan 2024 22:29:50 -0300 Subject: [PATCH 03/12] update docs --- .gitignore | 2 +- LICENSE.md | 4 +- README.md | 138 +++----------------- dev-requirements.txt | 5 - docs/index.md | 297 ------------------------------------------- docs/reference.md | 126 ++++++++++++++++++ fivbvis/version.py | 2 +- requirements.txt | 5 +- setup.py | 6 +- 9 files changed, 152 insertions(+), 433 deletions(-) delete mode 100644 dev-requirements.txt delete mode 100644 docs/index.md create mode 100644 docs/reference.md diff --git a/.gitignore b/.gitignore index 9cdb3d1..162a8c3 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,4 @@ request.txt /*.egg-info/ # env -/venv \ No newline at end of file +.venv \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md index f288702..245149a 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) + Copyright (C) 2022 Clarissa Mendes This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - Copyright (C) + FIVB VIS Python Client Copyright (C) 2022 Clarissa Mendes This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/README.md b/README.md index cb6daec..8cf066b 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,9 @@ [![PyPI](https://img.shields.io/pypi/v/fivbvis)](https://pypi.org/project/fivbvis/) -Python client library to easily integrate with [FIVB VIS Web Service](https://www.fivb.org/VisSDK/VisWebService/#Introduction.html) public data. +Python client library to easily integrate with [FIVB VIS Web Service](https://www.fivb.org/VisSDK/VisWebService/#Introduction.html) public data with JSON responses -Responses are formatted using JSON. - -**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB).** +**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB)** ## Requirements @@ -15,17 +13,20 @@ Responses are formatted using JSON. ## Installation ```shell -pip3 install fivbvis +pip install fivbvis ``` ## Usage +Basic example: + ```python from fivbvis import VolleyMatch vm = VolleyMatch() - print(vm.match(9211)) ``` +JSON return: + ```json { "data":{ @@ -35,126 +36,13 @@ print(vm.match(9211)) "beginDateTimeUtc":"2018-10-07T04:25:00Z", "buyTicketsUrl":"", "city":"Nagoya", - "countryCode":"JP", - "countryName":"Japan", - "dateLocal":"2018-10-07", - "dateTimeLocal":"2018-10-07T13:25:00", - "dateTimeUtc":"2018-10-07T04:25:00Z", - "durationSet1":1320, - "durationSet2":1560, - "durationSet3":2520, - "durationSet4":1680, - "durationSet5":1080, - "durationSet6":"None", - "durationSet7":"None", - "durationTotal":8160, - "endDateTimeUtc":"2018-10-07T06:53:00Z", - "endTime":"15:53:00", - "format":1, - "fullDuration":8880, - "hall":"Nippongaishi Hall", - "hasLiveData":1, - "isFreeEntrance":0, - "isVtsAvailable":0, - "lineJudge1CountryCode":"None", - "lineJudge1FirstName":"None", - "lineJudge1LastName":"None", - "lineJudge2CountryCode":"None", - "lineJudge2FirstName":"None", - "lineJudge2LastName":"None", - "lineJudge3CountryCode":"None", - "lineJudge3FirstName":"None", - "lineJudge3LastName":"None", - "lineJudge4CountryCode":"None", - "lineJudge4FirstName":"", - "lineJudge4LastName":"None", - "liveScoreFromScoresheet":1, - "liveStreamUri":"https://welcome.volleyballworld.tv/", - "loserRank":0, - "matchPointsA":3, - "matchPointsB":2, - "matchResultText":"3-2", - "nbSets":5, - "nbSpectators":3000, - "no":9211, - "noConfederation":"None", - "noDocumentP2":256122695, - "noEvent":658, - "noInTournament":63, - "noPool":2421, - "noPoolRound":130, - "noReferee1":150966, - "noReferee2":153275, - "noReferee3":"None", - "noRefereeChallenge":150773, - "noRefereeReserve":151023, - "noTeamA":3675, - "noTeamB":3694, - "noTournament":1029, - "pointsTeamASet1":14, - "pointsTeamASet2":19, - "pointsTeamASet3":32, - "pointsTeamASet4":25, - "pointsTeamASet5":17, - "pointsTeamASet6":"None", - "pointsTeamASet7":"None", - "pointsTeamBSet1":25, - "pointsTeamBSet2":25, - "pointsTeamBSet3":30, - "pointsTeamBSet4":19, - "pointsTeamBSet5":15, - "pointsTeamBSet6":"None", - "pointsTeamBSet7":"None", - "poolCode":"E", - "poolName":"Pool E", - "poolOrder":5, - "poolRoundCode":"II", - "poolRoundName":"Second round", - "referee1FederationCode":"KOR", - "referee1Name":"Kang Joo-Hee", - "referee2FederationCode":"ITA", - "referee2Name":"Rapisarda Daniele", - "resultType":0, - "resultTypeText":"None", - "scheduleInfo":4, - "scorerCountryCode":"None", - "scorerFirstName":"None", - "scorerLastName":"None", - "season":"2018", - "setsResultsText":"(14-25, 19-25, 32-30, 25-19, 17-15)", - "status":25, - "statusText":"Result is official", - "teamACalculatedCode":"GER", - "teamACalculatedName":"Germany", - "teamACode":"GER", - "teamALiberoUniformColor":"Red", - "teamAName":"Germany", - "teamAShirtColor":"Black", - "teamAText":"GER", - "teamBCalculatedCode":"BRA", - "teamBCalculatedName":"Brazil", - "teamBCode":"BRA", - "teamBLiberoUniformColor":"Blue", - "teamBName":"Brazil", - "teamBShirtColor":"Yellow", - "teamBText":"BRA", - "teamCodeA":"GER", - "teamCodeB":"BRA", - "teamNameA":"Germany", - "teamNameB":"Brazil", - "timeLocal":"13:25:00", - "tournamentCode":"WWCH2018", - "winnerRank":0 + ... } } ``` +## Documentation -## [Documentation](https://claromes.github.io/fivbvis) - -## Available Requests - -- Article -- VolleyMatch +[Web Service Requests Reference](docs/reference.md) ## Development @@ -162,4 +50,8 @@ $ `git clone git@github.com:claromes/fivbvis.git` $ `cd fivbvis` -$ `pip3 install -r dev-requirements.txt` +$ `pip install -r requirements.txt` + +## Author + +[Claromes](https://claromes.ocom) \ No newline at end of file diff --git a/dev-requirements.txt b/dev-requirements.txt deleted file mode 100644 index 021d23c..0000000 --- a/dev-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ --r requirements.txt - -pytest==7.2.0 -pytest-cov==4.1.0 -vcrpy==4.2.1 \ No newline at end of file diff --git a/docs/index.md b/docs/index.md deleted file mode 100644 index e1b4723..0000000 --- a/docs/index.md +++ /dev/null @@ -1,297 +0,0 @@ -# FIVB VIS Python Client - -[![PyPI](https://img.shields.io/pypi/v/fivbvis)](https://pypi.org/project/fivbvis/) [![License](https://img.shields.io/github/license/claromes/fivbvis)](https://github.com/claromes/fivbvis/blob/main/LICENSE.md) [![Star](https://img.shields.io/github/stars/claromes/fivbvis?style=social)](https://github.com/claromes/fivbvis) - -Python client library to easily integrate with [FIVB VIS Web Service](https://www.fivb.org/VisSDK/VisWebService/#Introduction.html) public data. - -Responses are formatted using JSON. - -**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB).** - -
- -# Docs - -## Requirements - -- Python 3.8+ - -## Installation - -```shell -pip3 install fivbvis -``` - -## Usage -```python -from fivbvis import VolleyMatch - -vm = VolleyMatch() - -print(vm.match(9211)) -``` -```json -{ - "data":{ - "assistantScorerCountryCode":"None", - "assistantScorerFirstName":"None", - "assistantScorerLastName":"None", - "beginDateTimeUtc":"2018-10-07T04:25:00Z", - "buyTicketsUrl":"", - "city":"Nagoya", - "countryCode":"JP", - "countryName":"Japan", - "dateLocal":"2018-10-07", - "dateTimeLocal":"2018-10-07T13:25:00", - "dateTimeUtc":"2018-10-07T04:25:00Z", - "durationSet1":1320, - "durationSet2":1560, - "durationSet3":2520, - "durationSet4":1680, - "durationSet5":1080, - "durationSet6":"None", - "durationSet7":"None", - "durationTotal":8160, - "endDateTimeUtc":"2018-10-07T06:53:00Z", - "endTime":"15:53:00", - "format":1, - "fullDuration":8880, - "hall":"Nippongaishi Hall", - "hasLiveData":1, - "isFreeEntrance":0, - "isVtsAvailable":0, - "lineJudge1CountryCode":"None", - "lineJudge1FirstName":"None", - "lineJudge1LastName":"None", - "lineJudge2CountryCode":"None", - "lineJudge2FirstName":"None", - "lineJudge2LastName":"None", - "lineJudge3CountryCode":"None", - "lineJudge3FirstName":"None", - "lineJudge3LastName":"None", - "lineJudge4CountryCode":"None", - "lineJudge4FirstName":"", - "lineJudge4LastName":"None", - "liveScoreFromScoresheet":1, - "liveStreamUri":"https://welcome.volleyballworld.tv/", - "loserRank":0, - "matchPointsA":3, - "matchPointsB":2, - "matchResultText":"3-2", - "nbSets":5, - "nbSpectators":3000, - "no":9211, - "noConfederation":"None", - "noDocumentP2":256122695, - "noEvent":658, - "noInTournament":63, - "noPool":2421, - "noPoolRound":130, - "noReferee1":150966, - "noReferee2":153275, - "noReferee3":"None", - "noRefereeChallenge":150773, - "noRefereeReserve":151023, - "noTeamA":3675, - "noTeamB":3694, - "noTournament":1029, - "pointsTeamASet1":14, - "pointsTeamASet2":19, - "pointsTeamASet3":32, - "pointsTeamASet4":25, - "pointsTeamASet5":17, - "pointsTeamASet6":"None", - "pointsTeamASet7":"None", - "pointsTeamBSet1":25, - "pointsTeamBSet2":25, - "pointsTeamBSet3":30, - "pointsTeamBSet4":19, - "pointsTeamBSet5":15, - "pointsTeamBSet6":"None", - "pointsTeamBSet7":"None", - "poolCode":"E", - "poolName":"Pool E", - "poolOrder":5, - "poolRoundCode":"II", - "poolRoundName":"Second round", - "referee1FederationCode":"KOR", - "referee1Name":"Kang Joo-Hee", - "referee2FederationCode":"ITA", - "referee2Name":"Rapisarda Daniele", - "resultType":0, - "resultTypeText":"None", - "scheduleInfo":4, - "scorerCountryCode":"None", - "scorerFirstName":"None", - "scorerLastName":"None", - "season":"2018", - "setsResultsText":"(14-25, 19-25, 32-30, 25-19, 17-15)", - "status":25, - "statusText":"Result is official", - "teamACalculatedCode":"GER", - "teamACalculatedName":"Germany", - "teamACode":"GER", - "teamALiberoUniformColor":"Red", - "teamAName":"Germany", - "teamAShirtColor":"Black", - "teamAText":"GER", - "teamBCalculatedCode":"BRA", - "teamBCalculatedName":"Brazil", - "teamBCode":"BRA", - "teamBLiberoUniformColor":"Blue", - "teamBName":"Brazil", - "teamBShirtColor":"Yellow", - "teamBText":"BRA", - "teamCodeA":"GER", - "teamCodeB":"BRA", - "teamNameA":"Germany", - "teamNameB":"Brazil", - "timeLocal":"13:25:00", - "tournamentCode":"WWCH2018", - "winnerRank":0 - } -} -``` - -## Requests - -### Article ----- - -`class` fivbvis.Article() - ->get(no, fields='') - -Get a article. - -- Parameters: - - `no` (int) - The number of the match. - - `fields` (str) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - -- Request example: - - ```python - from fivbvis import Article - - a = Article() - print(a.get(28639, 'No source isVideoLive')) - ``` - -- Return type: dict - ->list(fields, filter='', tags='') - -Get a list of article. - -- Parameters: - - `fields` (str) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - - `filter` (str) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) - - `tags` (str) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) - -- Request example: - - ```python - from fivbvis import Article - - a = Article() - print(a.list('No PhotoUrl PublishOnFivb ShareUrl', 'Home', 'volley-tournament:979')) - ``` - -- Return type: `dict` - -
- -### Beach ----- - -### Confederation ----- - -### Federation ----- - -### Image ----- - -### Match ----- - -### Phase ----- - -### Player ----- - -### Round ----- - -### Tournament ----- - -### VolleyClub ----- - -### VolleyLive ----- - -### VolleyMatch ----- - -`class` fivbvis.VolleyMatch() - ->match(no) - -Get a volleyball match. - -- Parameters: - - `no` (int) - The number of the match. - -- Request example: - - `match(9211)` - -- Return type: dict - ->list(no_tournament, fields='', filter='') - -Get a list of volleyball matches. - -- Parameters: - - `no_tournament` (int) - The number of the tournament. - - `fields` (str) - All the fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) - - `filter` (str, (optional)) - All the filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) - -- Request example: - - `list(979, 'City Hall MatchPointsA MatchPointsB', 'FirstDate="2017-07-01" LastDate="2017-07-31"')` - -- Return type: dict - -
- -### VolleyPlayer ----- - -### VolleyPool ----- - -### VolleyRankingDefinition ----- - -### VolleyStatistic ----- - -### VolleyTeam ----- - -### VolleyTournament ----- - -### VolleyTransfer ----- - -[VIS Web Service Requests full list](https://www.fivb.org/VisSDK/VisWebService/RequestList.html) - -## Author - -[claromes](https://claromes.gitlab.io/) \ No newline at end of file diff --git a/docs/reference.md b/docs/reference.md new file mode 100644 index 0000000..72c0d74 --- /dev/null +++ b/docs/reference.md @@ -0,0 +1,126 @@ +# Web Service Requests Reference + +## Article + +>`class` fivbvis.Article() + +### get(no, fields=None) + +Get an article. + +- Parameters: + - `no` (int, required) - The number of the match. + - `fields` (str, optional) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + +- Example: + + ```python + from fivbvis import Article + + a = Article() + print(a.get(69213, 'no source isVideoLive')) + ``` + +- Return type: `dict` + +### list(fields, filter=None, tags=None) + +Get a list of article. + +- Parameters: + - `fields` (str, required) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + - `filter` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) + - `tags` (str, optional) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) + +- Example: + + ```python + from fivbvis import Article + + a = Article() + print(a.list('no photoUrl publishOnFivb shareUrl', 'home', 'volley-tournament:979')) + ``` + +- Return type: `dict` + +
+ +## Beach + +## Confederation + +## Federation + +## Image + +## Match + +## Phase + +## Player + +## Round + +## Tournament + +## VolleyClub + +## VolleyLive + +## VolleyMatch + +>`class` fivbvis.VolleyMatch() + +### match(no) + +Get a volleyball match. + +- Parameters: + - `no` (int, required) - The number of the match. + +- Example: + + ```python + from fivbvis import VolleyMatch + + vm = VolleyMatch() + print(vm.match(9211)) + ``` + +- Return type: `dict` + +### list(no_tournament, fields=None, filter=None) + +Get a list of volleyball matches. + +- Parameters: + - `no_tournament` (int, required) - The number of the tournament. + - `fields` (str, optional) - All the fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) + - `filter` (str, optional) - All the filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) + +- Example: + + ```python + from fivbvis import VolleyMatch + + vm = VolleyMatch() + print(vm.list(979, 'city hall matchPointsA matchPointsB', 'firstDate="2017-07-01" lastDate="2017-07-31"')) + ``` + +- Return type: `dict` + +
+ +## VolleyPlayer + +## VolleyPool + +## VolleyRankingDefinition + +## VolleyStatistic + +## VolleyTeam + +## VolleyTournament + +## VolleyTransfer diff --git a/fivbvis/version.py b/fivbvis/version.py index ef0b380..edcfd0d 100644 --- a/fivbvis/version.py +++ b/fivbvis/version.py @@ -1 +1 @@ -__version__ = '0.1.3' \ No newline at end of file +__version__ = '0.2' \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5e77405..909b9da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,4 @@ -requests==2.28.1 \ No newline at end of file +requests==2.28.1 +pytest==7.2.0 +pytest-cov==4.1.0 +vcrpy==4.2.1 \ No newline at end of file diff --git a/setup.py b/setup.py index 201b7e0..00fb66f 100644 --- a/setup.py +++ b/setup.py @@ -14,14 +14,14 @@ setup( name='fivbvis', version=version, - author='claromes', + author='Claromes', description='FIVB VIS Web Service Python Client', long_description=long_description, long_description_content_type='text/markdown', - keywords='api-wrapper fivbvis fivb volleyball beachvolleyball', + keywords='fivbvis fivb volleyball beachvolleyball sports', url='https://github.com/claromes/fivbvis', project_urls={ - 'Documentation': 'https://claromes.github.io/fivbvis/', + 'Documentation': 'https://github.com/claromes/fivbvis/docs/reference.md', 'Issue Tracker': 'https://github.com/claromes/fivbvis/issues', }, packages=find_packages(exclude=['docs', 'tests*']), From 90cc35ab992cdd3d27cf0079caa34b3758403a28 Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 03:39:24 -0300 Subject: [PATCH 04/12] add default filters to vm list --- docs/reference.md | 22 +++++++++++++--------- fivbvis/volley_match.py | 5 ++++- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index 72c0d74..ea996e9 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,13 +4,13 @@ >`class` fivbvis.Article() -### get(no, fields=None) +### get(no, fields="") Get an article. - Parameters: - `no` (int, required) - The number of the match. - - `fields` (str, optional) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + - `fields` (str, optional) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - Example: @@ -23,12 +23,12 @@ Get an article. - Return type: `dict` -### list(fields, filter=None, tags=None) +### list(fields, filter="", tags="") Get a list of article. - Parameters: - - `fields` (str, required) - All the fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + - `fields` (str, required) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - `filter` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) - `tags` (str, optional) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) @@ -38,7 +38,7 @@ Get a list of article. from fivbvis import Article a = Article() - print(a.list('no photoUrl publishOnFivb shareUrl', 'home', 'volley-tournament:979')) + print(a.list('No PhotoUrl PublishOnFivb ShareUrl', 'Home', 'volley-tournament:979')) ``` - Return type: `dict` @@ -89,14 +89,18 @@ Get a volleyball match. - Return type: `dict` -### list(no_tournament, fields=None, filter=None) +### list(no_tournament, fields="City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName", filter="") Get a list of volleyball matches. +If the `fields` parameter is not passed, the following fields will be applied: `city, countryName, dateTimeLocal, durationTotal, hall, matchPointsA, matchPointsB, matchResultText, no, noTournament, season, teamAName, teamBName`. + +Requesting all parameters may result in a 404 error. + - Parameters: - `no_tournament` (int, required) - The number of the tournament. - - `fields` (str, optional) - All the fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) - - `filter` (str, optional) - All the filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) + - `fields` (str, optional) - Fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) + - `filter` (str, optional) - Filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) - Example: @@ -104,7 +108,7 @@ Get a list of volleyball matches. from fivbvis import VolleyMatch vm = VolleyMatch() - print(vm.list(979, 'city hall matchPointsA matchPointsB', 'firstDate="2017-07-01" lastDate="2017-07-31"')) + print(vm.list(979, filter='FirstDate="2017-7-5" LastDate="2017-7-5"')) ``` - Return type: `dict` diff --git a/fivbvis/volley_match.py b/fivbvis/volley_match.py index c951149..501e0cb 100644 --- a/fivbvis/volley_match.py +++ b/fivbvis/volley_match.py @@ -12,7 +12,10 @@ def match(self, no): return response.json() - def list(self, no_tournament, fields, filter=''): + def list(self, + no_tournament, + fields='City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName', + filter=''): url = self.base_url + "".format(fields, filter, no_tournament) response = requests.get(url, headers=self.headers) From 9d44adfa2c52ba2db60cd79f3e1cc51d0ec8e5ef Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 04:10:51 -0300 Subject: [PATCH 05/12] add default filters to a list --- docs/reference.md | 12 ++++++++---- fivbvis/article.py | 6 ++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index ea996e9..d43f586 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,10 +4,12 @@ >`class` fivbvis.Article() -### get(no, fields="") +### get(no, fields) Get an article. +If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. + - Parameters: - `no` (int, required) - The number of the match. - `fields` (str, optional) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) @@ -23,10 +25,12 @@ Get an article. - Return type: `dict` -### list(fields, filter="", tags="") +### list(fields, filter, tags) Get a list of article. +If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. + - Parameters: - `fields` (str, required) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - `filter` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) @@ -89,11 +93,11 @@ Get a volleyball match. - Return type: `dict` -### list(no_tournament, fields="City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName", filter="") +### list(no_tournament, fields, filter) Get a list of volleyball matches. -If the `fields` parameter is not passed, the following fields will be applied: `city, countryName, dateTimeLocal, durationTotal, hall, matchPointsA, matchPointsB, matchResultText, no, noTournament, season, teamAName, teamBName`. +If the `fields` parameter is not passed, the following fields will be applied: `city countryName dateTimeLocal durationTotal hall matchPointsA matchPointsB matchResultText no noTournament season teamAName teamBName`. Requesting all parameters may result in a 404 error. diff --git a/fivbvis/article.py b/fivbvis/article.py index 1d50dfa..123487e 100644 --- a/fivbvis/article.py +++ b/fivbvis/article.py @@ -1,18 +1,20 @@ import requests +FIELDS = 'DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri' + class Article(): def __init__(self): self.headers = {'Accept': 'application/json'} self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" - def get(self, no, fields=''): + def get(self, no, fields=FIELDS): url = self.base_url + "".format(no, fields) response = requests.get(url, headers=self.headers) return response.json() - def list(self, fields, filter='', tags=''): + def list(self, fields=FIELDS, filter='', tags=''): url = self.base_url + "'{}'{}".format(fields, filter, tags) response = requests.get(url, headers=self.headers) From 53f2a665ed148cee65efc92a3f46978fc48864b1 Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 04:17:37 -0300 Subject: [PATCH 06/12] change param Filter to Filters --- docs/reference.md | 14 +++++++------- fivbvis/article.py | 4 ++-- fivbvis/volley_match.py | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index d43f586..6060ceb 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -20,12 +20,12 @@ If the `fields` parameter is not passed, the following fields will be applied: ` from fivbvis import Article a = Article() - print(a.get(69213, 'no source isVideoLive')) + print(a.get(no=69213, fields='no source isVideoLive')) ``` - Return type: `dict` -### list(fields, filter, tags) +### list(fields, filters, tags) Get a list of article. @@ -33,7 +33,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` - Parameters: - `fields` (str, required) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - - `filter` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) + - `filters` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) - `tags` (str, optional) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) - Example: @@ -42,7 +42,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` from fivbvis import Article a = Article() - print(a.list('No PhotoUrl PublishOnFivb ShareUrl', 'Home', 'volley-tournament:979')) + print(a.list(filters='Home', tags='volley-tournament:979')) ``` - Return type: `dict` @@ -93,7 +93,7 @@ Get a volleyball match. - Return type: `dict` -### list(no_tournament, fields, filter) +### list(no_tournament, fields, filters) Get a list of volleyball matches. @@ -104,7 +104,7 @@ Requesting all parameters may result in a 404 error. - Parameters: - `no_tournament` (int, required) - The number of the tournament. - `fields` (str, optional) - Fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) - - `filter` (str, optional) - Filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) + - `filters` (str, optional) - Filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) - Example: @@ -112,7 +112,7 @@ Requesting all parameters may result in a 404 error. from fivbvis import VolleyMatch vm = VolleyMatch() - print(vm.list(979, filter='FirstDate="2017-7-5" LastDate="2017-7-5"')) + print(vm.list(no_tournament=979, filters='FirstDate="2017-7-5" LastDate="2017-7-5"')) ``` - Return type: `dict` diff --git a/fivbvis/article.py b/fivbvis/article.py index 123487e..30f13b3 100644 --- a/fivbvis/article.py +++ b/fivbvis/article.py @@ -14,8 +14,8 @@ def get(self, no, fields=FIELDS): return response.json() - def list(self, fields=FIELDS, filter='', tags=''): - url = self.base_url + "'{}'{}".format(fields, filter, tags) + def list(self, fields=FIELDS, filters='', tags=''): + url = self.base_url + "'{}'{}".format(fields, filters, tags) response = requests.get(url, headers=self.headers) diff --git a/fivbvis/volley_match.py b/fivbvis/volley_match.py index 501e0cb..ac66a5e 100644 --- a/fivbvis/volley_match.py +++ b/fivbvis/volley_match.py @@ -15,8 +15,8 @@ def match(self, no): def list(self, no_tournament, fields='City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName', - filter=''): - url = self.base_url + "".format(fields, filter, no_tournament) + filters=''): + url = self.base_url + "".format(fields, filters, no_tournament) response = requests.get(url, headers=self.headers) From 36eae993c442950ac24981c61728d8168ccf87d2 Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 04:20:48 -0300 Subject: [PATCH 07/12] use f-strings --- fivbvis/article.py | 4 ++-- fivbvis/volley_match.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fivbvis/article.py b/fivbvis/article.py index 30f13b3..09a9036 100644 --- a/fivbvis/article.py +++ b/fivbvis/article.py @@ -8,14 +8,14 @@ def __init__(self): self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" def get(self, no, fields=FIELDS): - url = self.base_url + "".format(no, fields) + url = self.base_url + f"" response = requests.get(url, headers=self.headers) return response.json() def list(self, fields=FIELDS, filters='', tags=''): - url = self.base_url + "'{}'{}".format(fields, filters, tags) + url = self.base_url + f"'{filters}'{tags}" response = requests.get(url, headers=self.headers) diff --git a/fivbvis/volley_match.py b/fivbvis/volley_match.py index ac66a5e..93e4389 100644 --- a/fivbvis/volley_match.py +++ b/fivbvis/volley_match.py @@ -6,7 +6,7 @@ def __init__(self): self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" def match(self, no): - url = self.base_url + "".format(no) + url = self.base_url + f"" response = requests.get(url, headers=self.headers) @@ -16,7 +16,7 @@ def list(self, no_tournament, fields='City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName', filters=''): - url = self.base_url + "".format(fields, filters, no_tournament) + url = self.base_url + f"" response = requests.get(url, headers=self.headers) From dbf91a5bb9a88d5abba149dbdb1bf1be552fa092 Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 17:09:43 -0300 Subject: [PATCH 08/12] add response format option --- README.md | 7 ++++--- docs/reference.md | 20 ++++++++------------ fivbvis/article.py | 29 ++++++++++++++++++++++------- fivbvis/volley_match.py | 34 ++++++++++++++++++++++++---------- 4 files changed, 58 insertions(+), 32 deletions(-) diff --git a/README.md b/README.md index 8cf066b..24743ca 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,9 @@ [![PyPI](https://img.shields.io/pypi/v/fivbvis)](https://pypi.org/project/fivbvis/) -Python client library to easily integrate with [FIVB VIS Web Service](https://www.fivb.org/VisSDK/VisWebService/#Introduction.html) public data with JSON responses +Python client library for easy integration with [FIVB VIS Web Service](https://www.fivb.org/VisSDK/VisWebService/#Introduction.html) public data, providing XML and JSON responses. -**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB)** +**This client is not affiliated with the Fédération Internationale de Volleyball (FIVB).** ## Requirements @@ -23,7 +23,7 @@ Basic example: from fivbvis import VolleyMatch vm = VolleyMatch() -print(vm.match(9211)) +print(vm.match(9211, response_format="json")) ``` JSON return: @@ -36,6 +36,7 @@ JSON return: "beginDateTimeUtc":"2018-10-07T04:25:00Z", "buyTicketsUrl":"", "city":"Nagoya", + "countryCode":"JP", ... } } diff --git a/docs/reference.md b/docs/reference.md index 6060ceb..ce8bd56 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,7 +4,7 @@ >`class` fivbvis.Article() -### get(no, fields) +### get(no, fields, response_format) Get an article. @@ -13,6 +13,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` - Parameters: - `no` (int, required) - The number of the match. - `fields` (str, optional) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. - Example: @@ -23,9 +24,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` print(a.get(no=69213, fields='no source isVideoLive')) ``` -- Return type: `dict` - -### list(fields, filters, tags) +### list(fields, filters, tags, response_format) Get a list of article. @@ -35,6 +34,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` - `fields` (str, required) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) - `filters` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) - `tags` (str, optional) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) + - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. - Example: @@ -45,8 +45,6 @@ If the `fields` parameter is not passed, the following fields will be applied: ` print(a.list(filters='Home', tags='volley-tournament:979')) ``` -- Return type: `dict` -
## Beach @@ -75,12 +73,13 @@ If the `fields` parameter is not passed, the following fields will be applied: ` >`class` fivbvis.VolleyMatch() -### match(no) +### match(no, response_format) Get a volleyball match. - Parameters: - `no` (int, required) - The number of the match. + - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. - Example: @@ -91,9 +90,7 @@ Get a volleyball match. print(vm.match(9211)) ``` -- Return type: `dict` - -### list(no_tournament, fields, filters) +### list(no_tournament, fields, filters, response_format) Get a list of volleyball matches. @@ -105,6 +102,7 @@ Requesting all parameters may result in a 404 error. - `no_tournament` (int, required) - The number of the tournament. - `fields` (str, optional) - Fields in the volleyball match data. Must be space-separated. [(Fields/Properties list of each match)](https://www.fivb.org/VisSDK/VisWebService/#VolleyMatch.html) - `filters` (str, optional) - Filters in the volleyball match data. Must be space-separated. [(Filter list of each match)](https://www.fivb.org/VisSDK/VisWebService/VolleyMatchFilter.html) + - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. - Example: @@ -115,8 +113,6 @@ Requesting all parameters may result in a 404 error. print(vm.list(no_tournament=979, filters='FirstDate="2017-7-5" LastDate="2017-7-5"')) ``` -- Return type: `dict` -
## VolleyPlayer diff --git a/fivbvis/article.py b/fivbvis/article.py index 09a9036..2f1cd4a 100644 --- a/fivbvis/article.py +++ b/fivbvis/article.py @@ -4,19 +4,34 @@ class Article(): def __init__(self): - self.headers = {'Accept': 'application/json'} self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" - def get(self, no, fields=FIELDS): + def get(self, no, fields=FIELDS, response_format='xml'): url = self.base_url + f"" - response = requests.get(url, headers=self.headers) + if response_format != 'json' and response_format != 'xml': + raise ValueError(f'{response_format}: The provided value is not accepted.') + + headers = {'Accept': f'application/{response_format}'} - return response.json() + response = requests.get(url, headers=headers) - def list(self, fields=FIELDS, filters='', tags=''): + if response_format == 'xml': + return response.text + elif response_format == 'json': + return response.json() + + def list(self, fields=FIELDS, filters='', tags='', response_format='xml'): url = self.base_url + f"'{filters}'{tags}" - response = requests.get(url, headers=self.headers) + if response_format != 'json' and response_format != 'xml': + raise ValueError(f'{response_format}: The provided value is not accepted.') + + headers = {'Accept': f'application/{response_format}'} + + response = requests.get(url, headers=headers) - return response.json() \ No newline at end of file + if response_format == 'xml': + return response.text + elif response_format == 'json': + return response.json() \ No newline at end of file diff --git a/fivbvis/volley_match.py b/fivbvis/volley_match.py index 93e4389..13d7daa 100644 --- a/fivbvis/volley_match.py +++ b/fivbvis/volley_match.py @@ -1,23 +1,37 @@ import requests +FIELDS = 'City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName' + class VolleyMatch(): def __init__(self): - self.headers = {'Accept': 'application/json'} self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" - def match(self, no): + def match(self, no, response_format='xml'): url = self.base_url + f"" - response = requests.get(url, headers=self.headers) + if response_format != 'json' and response_format != 'xml': + raise ValueError(f'{response_format}: The provided value is not accepted.') + + headers = {'Accept': f'application/{response_format}'} + + response = requests.get(url, headers=headers) - return response.json() + if response_format == 'xml': + return response.text + elif response_format == 'json': + return response.json() - def list(self, - no_tournament, - fields='City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName', - filters=''): + def list(self, no_tournament, fields=FIELDS, filters='', response_format='xml'): url = self.base_url + f"" - response = requests.get(url, headers=self.headers) + if response_format != 'json' and response_format != 'xml': + raise ValueError(f'{response_format}: The provided value is not accepted.') + + headers = {'Accept': f'application/{response_format}'} + + response = requests.get(url, headers=headers) - return response.json() \ No newline at end of file + if response_format == 'xml': + return response.text + elif response_format == 'json': + return response.json() \ No newline at end of file From c1eda3c0e88246deedc95dcaa1222044d3173b4c Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 22:26:50 -0300 Subject: [PATCH 09/12] rewrite classes --- README.md | 2 +- docs/reference.md | 16 +++++++-------- fivbvis/__init__.py | 4 ++-- fivbvis/article.py | 37 --------------------------------- fivbvis/default_fields.py | 3 +++ fivbvis/fivbvis.py | 33 ++++++++++++++++++++++++++++++ fivbvis/references.py | 28 +++++++++++++++++++++++++ fivbvis/volley_match.py | 37 --------------------------------- requirements.txt | 5 +---- tests/__init__.py | 0 tests/test_article.py | 20 ------------------ tests/test_volley_match.py | 42 -------------------------------------- 12 files changed, 76 insertions(+), 151 deletions(-) delete mode 100644 fivbvis/article.py create mode 100644 fivbvis/default_fields.py create mode 100644 fivbvis/fivbvis.py create mode 100644 fivbvis/references.py delete mode 100644 fivbvis/volley_match.py delete mode 100644 tests/__init__.py delete mode 100644 tests/test_article.py delete mode 100644 tests/test_volley_match.py diff --git a/README.md b/README.md index 24743ca..04f7cd1 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Basic example: from fivbvis import VolleyMatch vm = VolleyMatch() -print(vm.match(9211, response_format="json")) +print(vm.getMatch(9211, response_format="json")) ``` JSON return: diff --git a/docs/reference.md b/docs/reference.md index ce8bd56..a8356ac 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -4,7 +4,7 @@ >`class` fivbvis.Article() -### get(no, fields, response_format) +### getArticle(no, fields, response_format) Get an article. @@ -21,10 +21,10 @@ If the `fields` parameter is not passed, the following fields will be applied: ` from fivbvis import Article a = Article() - print(a.get(no=69213, fields='no source isVideoLive')) + print(a.getArticle(no=69213, fields='no source isVideoLive')) ``` -### list(fields, filters, tags, response_format) +### getArticleList(fields, filters, tags, response_format) Get a list of article. @@ -42,7 +42,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` from fivbvis import Article a = Article() - print(a.list(filters='Home', tags='volley-tournament:979')) + print(a.getArticleList(filters='Home', tags='volley-tournament:979')) ```
@@ -73,7 +73,7 @@ If the `fields` parameter is not passed, the following fields will be applied: ` >`class` fivbvis.VolleyMatch() -### match(no, response_format) +### getMatch(no, response_format) Get a volleyball match. @@ -87,10 +87,10 @@ Get a volleyball match. from fivbvis import VolleyMatch vm = VolleyMatch() - print(vm.match(9211)) + print(vm.getMatch(9211)) ``` -### list(no_tournament, fields, filters, response_format) +### getMatchList(no_tournament, fields, filters, response_format) Get a list of volleyball matches. @@ -110,7 +110,7 @@ Requesting all parameters may result in a 404 error. from fivbvis import VolleyMatch vm = VolleyMatch() - print(vm.list(no_tournament=979, filters='FirstDate="2017-7-5" LastDate="2017-7-5"')) + print(vm.getMatchList(no_tournament=979, filters='FirstDate="2017-7-5" LastDate="2017-7-5"')) ```
diff --git a/fivbvis/__init__.py b/fivbvis/__init__.py index be4a260..f4cc699 100644 --- a/fivbvis/__init__.py +++ b/fivbvis/__init__.py @@ -1,5 +1,5 @@ -from .volley_match import VolleyMatch -from .article import Article +from .fivbvis import FivbVis +from .references import Article, VolleyMatch from . import version diff --git a/fivbvis/article.py b/fivbvis/article.py deleted file mode 100644 index 2f1cd4a..0000000 --- a/fivbvis/article.py +++ /dev/null @@ -1,37 +0,0 @@ -import requests - -FIELDS = 'DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri' - -class Article(): - def __init__(self): - self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" - - def get(self, no, fields=FIELDS, response_format='xml'): - url = self.base_url + f"" - - if response_format != 'json' and response_format != 'xml': - raise ValueError(f'{response_format}: The provided value is not accepted.') - - headers = {'Accept': f'application/{response_format}'} - - response = requests.get(url, headers=headers) - - if response_format == 'xml': - return response.text - elif response_format == 'json': - return response.json() - - def list(self, fields=FIELDS, filters='', tags='', response_format='xml'): - url = self.base_url + f"'{filters}'{tags}" - - if response_format != 'json' and response_format != 'xml': - raise ValueError(f'{response_format}: The provided value is not accepted.') - - headers = {'Accept': f'application/{response_format}'} - - response = requests.get(url, headers=headers) - - if response_format == 'xml': - return response.text - elif response_format == 'json': - return response.json() \ No newline at end of file diff --git a/fivbvis/default_fields.py b/fivbvis/default_fields.py new file mode 100644 index 0000000..474457d --- /dev/null +++ b/fivbvis/default_fields.py @@ -0,0 +1,3 @@ +ARTICLE_DEFAULT_FIELDS = 'DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri' + +VOLLEY_MATCH_LIST_DEFAULT_FIELDS = 'City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName' \ No newline at end of file diff --git a/fivbvis/fivbvis.py b/fivbvis/fivbvis.py new file mode 100644 index 0000000..249a2f3 --- /dev/null +++ b/fivbvis/fivbvis.py @@ -0,0 +1,33 @@ +import requests + +class FivbVis(): + def __init__(self): + self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" + + def make_request(self, url, request_type, response_format): + if response_format != 'json' and response_format != 'xml': + raise ValueError(f'{response_format}: The provided value is not accepted.') + + headers = {'Accept': f'application/{response_format}'} + response = requests.get(url, headers=headers) + + if response_format == 'xml': + return response.text + elif response_format == 'json': + return response.json() + + def get(self, request_type, no, response_format): + url = self.base_url + f"" + return self.make_request(url, request_type, response_format) + + def get_with_fields(self, request_type, no, fields, response_format): + url = self.base_url + f"" + return self.make_request(url, request_type, response_format) + + def get_list(self, request_type, no_tournament, fields, filters, response_format): + url = self.base_url + f"" + return self.make_request(url, request_type, response_format) + + def get_list_with_tags(self, request_type, fields, filters, tags, response_format): + url = self.base_url + f"'{filters}'{tags}" + return self.make_request(url, request_type, response_format) \ No newline at end of file diff --git a/fivbvis/references.py b/fivbvis/references.py new file mode 100644 index 0000000..c50ee66 --- /dev/null +++ b/fivbvis/references.py @@ -0,0 +1,28 @@ +import requests + +from .fivbvis import FivbVis +from .default_fields import * + +class Article(FivbVis): + def __init__(self): + self.fivb_vis = FivbVis() + + def getArticle(self, no, fields=ARTICLE_DEFAULT_FIELDS, response_format='xml'): + result = self.fivb_vis.get_with_fields('GetArticle', no, fields, response_format) + return result + + def getArticleList(self, fields=ARTICLE_DEFAULT_FIELDS, filters='', tags='', response_format='xml'): + result = self.fivb_vis.get_list_with_tags('GetArticleList', fields, filters, tags, response_format) + return result + +class VolleyMatch(FivbVis): + def __init__(self): + self.fivb_vis = FivbVis() + + def getMatch(self, no, response_format='xml'): + result = self.fivb_vis.get('GetVolleyMatch', no, response_format) + return result + + def getMatchList(self, no_tournament, fields=VOLLEY_MATCH_LIST_DEFAULT_FIELDS, filters='', response_format='xml'): + result = self.fivb_vis.get_list('GetVolleyMatchList', no_tournament, fields, filters, response_format) + return result diff --git a/fivbvis/volley_match.py b/fivbvis/volley_match.py deleted file mode 100644 index 13d7daa..0000000 --- a/fivbvis/volley_match.py +++ /dev/null @@ -1,37 +0,0 @@ -import requests - -FIELDS = 'City CountryName DateTimeLocal DurationTotal Hall MatchPointsA MatchPointsB MatchResultText No NoTournament Season TeamAName TeamBName' - -class VolleyMatch(): - def __init__(self): - self.base_url = "https://www.fivb.org/Vis2009/XmlRequest.asmx?Request=" - - def match(self, no, response_format='xml'): - url = self.base_url + f"" - - if response_format != 'json' and response_format != 'xml': - raise ValueError(f'{response_format}: The provided value is not accepted.') - - headers = {'Accept': f'application/{response_format}'} - - response = requests.get(url, headers=headers) - - if response_format == 'xml': - return response.text - elif response_format == 'json': - return response.json() - - def list(self, no_tournament, fields=FIELDS, filters='', response_format='xml'): - url = self.base_url + f"" - - if response_format != 'json' and response_format != 'xml': - raise ValueError(f'{response_format}: The provided value is not accepted.') - - headers = {'Accept': f'application/{response_format}'} - - response = requests.get(url, headers=headers) - - if response_format == 'xml': - return response.text - elif response_format == 'json': - return response.json() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 909b9da..5e77405 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1 @@ -requests==2.28.1 -pytest==7.2.0 -pytest-cov==4.1.0 -vcrpy==4.2.1 \ No newline at end of file +requests==2.28.1 \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/tests/test_article.py b/tests/test_article.py deleted file mode 100644 index b79848c..0000000 --- a/tests/test_article.py +++ /dev/null @@ -1,20 +0,0 @@ -import vcr - -from pytest import fixture -from fivbvis import Article - -#Single Article -@fixture -def article_get_keys(): - return {'data': {'no', 'source', 'publishOnHome', 'videoUri', 'isVideoLive'}} - -@vcr.use_cassette('tests/vcr_cassettes/article-get-data.yaml') -def test_article_get(article_get_keys): - #API call to GET a Article data - - article_get_instance = Article() - response = article_get_instance.get(28639, 'No') - - assert isinstance(response, dict) - assert response['data']['no'] == 28639, 'The Article Number should be in the response' - assert set(article_get_keys).issubset(response.keys()), 'All keys should be in the response' \ No newline at end of file diff --git a/tests/test_volley_match.py b/tests/test_volley_match.py deleted file mode 100644 index 6819d61..0000000 --- a/tests/test_volley_match.py +++ /dev/null @@ -1,42 +0,0 @@ -import vcr - -from pytest import fixture -from fivbvis import VolleyMatch - -#Single Match -@fixture -def volley_match_keys(): - return {'data': {'no', 'dateTimeLocal', 'city', 'hall', 'teamA', 'teamB', 'tournament'}} - -@vcr.use_cassette('tests/vcr_cassettes/volley-match-data.yaml') -def test_volley_match(volley_match_keys): - #API call to GET a Volleyball match data - - volley_match_instance = VolleyMatch() - response = volley_match_instance.match(7604) - - assert isinstance(response, dict) - assert response['data']['no'] == 7604, 'The Match Number should be in the response' - assert set(volley_match_keys).issubset(response.keys()), 'All keys should be in the response' - -#Match List -@fixture -def volley_list_keys(): - return {'data': [{'no', 'teamA', 'teamB', 'noTournament'}, {'no', 'teamA', 'teamB', 'noTournament'}]} - -@vcr.use_cassette('tests/vcr_cassettes/volley-list-data.yaml') -def test_volley_list(volley_list_keys): - #API call to GET a Volleyball list data - - volley_list_instance = VolleyMatch() - response = volley_list_instance.list(979, "no teamA teamB noTournament", "FirstDate='2017-07-01' LastDate='2017-07-31'") - - assert isinstance(response, dict) - - assert response['data'][0]['noTournament'] == 979, 'The Tournament Number of the first match should be in the response' - assert response['data'][1]['noTournament'] == 979, 'The Tournament Number of the second match should be in the response' - - assert response['data'][0]['no'] == 7595, 'The first Match Number should be in the response' - assert response['data'][1]['no'] == 7596, 'The second Match Number should be in the response' - - assert set(volley_list_keys).issubset(response.keys()), 'All keys should be in the response' \ No newline at end of file From fda3c3e201dc830720f7dd8b041743bc8d68e3db Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 22:31:32 -0300 Subject: [PATCH 10/12] update setup --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 00fb66f..948efe0 100644 --- a/setup.py +++ b/setup.py @@ -24,7 +24,7 @@ 'Documentation': 'https://github.com/claromes/fivbvis/docs/reference.md', 'Issue Tracker': 'https://github.com/claromes/fivbvis/issues', }, - packages=find_packages(exclude=['docs', 'tests*']), + packages=find_packages(exclude=['docs']), classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Science/Research', From a519e16610f5ea325041258a421280d6b63a06bd Mon Sep 17 00:00:00 2001 From: Claromes Date: Mon, 15 Jan 2024 23:10:16 -0300 Subject: [PATCH 11/12] update docs/refs --- docs/reference.md | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/reference.md b/docs/reference.md index a8356ac..b80c525 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -2,17 +2,18 @@ ## Article ->`class` fivbvis.Article() +`class` Article() -### getArticle(no, fields, response_format) +> ### getArticle(no, fields, response_format) Get an article. -If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. - - Parameters: - - `no` (int, required) - The number of the match. + - `no` (int, required) - The number of the article. - `fields` (str, optional) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + + If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. + - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. - Example: @@ -24,14 +25,17 @@ If the `fields` parameter is not passed, the following fields will be applied: ` print(a.getArticle(no=69213, fields='no source isVideoLive')) ``` -### getArticleList(fields, filters, tags, response_format) +
-Get a list of article. +> ### getArticleList(fields, filters, tags, response_format) -If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. +Get a list of article. - Parameters: - `fields` (str, required) - Fields in the article data. Must be space-separated. [(Fields/Properties list of each article)](https://www.fivb.org/VisSDK/VisWebService/Article.html) + + If the `fields` parameter is not passed, the following fields will be applied: `DateTime DeletedDT ENewsLocation HasPhoto IsVideoLive LastChangeDT LastChangeUser LastChangeUsername No PhotoUrl PublishOnBeach PublishOnDevelopment PublishOnFivb PublishOnHeadlines PublishOnHome PublishOnMedical PublishOnMsdp PublishOnPresident PublishOnRefereeingRules PublishOnSnow PublishOnTechnicalCoach PublishOnTournament PublishOnTwitter PublishOnVolley PublishOnVolleyballWorld PublishOnWorldVolleyNews ShareUrl Source Url ValidFrom ValidTo DateTime Version VideoUri`. + - `filters` (str, optional) - Where the articles were published. Must be space-separated. [(Filter for an article)](https://www.fivb.org/VisSDK/VisWebService/ArticleFilter.html) - `tags` (str, optional) - Tags in the article data. Must be space-separated. [(Tags Filtering examples)](https://www.fivb.org/VisSDK/VisWebService/TagFiltering.html) - `response_format` (str, optional) - The response format: "xml" or "json". By default the response format is XML. @@ -71,9 +75,9 @@ If the `fields` parameter is not passed, the following fields will be applied: ` ## VolleyMatch ->`class` fivbvis.VolleyMatch() +`class` VolleyMatch() -### getMatch(no, response_format) +> ### getMatch(no, response_format) Get a volleyball match. @@ -90,7 +94,9 @@ Get a volleyball match. print(vm.getMatch(9211)) ``` -### getMatchList(no_tournament, fields, filters, response_format) +
+ +> ### getMatchList(no_tournament, fields, filters, response_format) Get a list of volleyball matches. From 1765d8898f185eaeae8d9be3be29c167a1bc8cd9 Mon Sep 17 00:00:00 2001 From: Claromes Date: Tue, 16 Jan 2024 00:38:53 -0300 Subject: [PATCH 12/12] update docs --- README.md | 4 +++- docs/reference.md | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 04f7cd1..00b7173 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,8 @@ $ `cd fivbvis` $ `pip install -r requirements.txt` +$ `pip install --editable .` + ## Author -[Claromes](https://claromes.ocom) \ No newline at end of file +[Claromes](https://claromes.com) \ No newline at end of file diff --git a/docs/reference.md b/docs/reference.md index b80c525..4128b2d 100644 --- a/docs/reference.md +++ b/docs/reference.md @@ -22,7 +22,7 @@ Get an article. from fivbvis import Article a = Article() - print(a.getArticle(no=69213, fields='no source isVideoLive')) + print(a.getArticle(no=69213, fields="no source isVideoLive")) ```
@@ -46,7 +46,7 @@ Get a list of article. from fivbvis import Article a = Article() - print(a.getArticleList(filters='Home', tags='volley-tournament:979')) + print(a.getArticleList(filters="Home", tags="volley-tournament:979")) ```