Skip to content

Removed API dependency for Tags - #803

Merged
ikuyarihS merged 22 commits into
python-discord:masterfrom
RohanJnr:tags_overhaul
Mar 15, 2020
Merged

Removed API dependency for Tags#803
ikuyarihS merged 22 commits into
python-discord:masterfrom
RohanJnr:tags_overhaul

Conversation

@RohanJnr

@RohanJnr RohanJnr commented Feb 29, 2020

Copy link
Copy Markdown
Contributor

closes #777

This PR is to remove the API dependency for the Tags and use static files instead, so adding, editing or deleting of a tag will happen only through a PR and not from a discord bot command.

  • Added all the static tag files in the resources folder.
  • Added white spaces on the lines before the bullet points for proper GitHub rendering of .md files.
  • Modified cogs/tags.py to use the static files rather than using the API. Removed all methods which call the API for adding, editing or deleting tags.

…o access the static tag files rather than sending an API get request. Removed all methods calling the API so the tags cannot be edited, added nor deleted.
@RohanJnr
RohanJnr requested a review from a team as a code owner February 29, 2020 09:55
@RohanJnr
RohanJnr requested review from MarkKoz and tagptroll1 and removed request for a team February 29, 2020 09:55
Comment thread bot/cogs/tags.py
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
@MarkKoz MarkKoz added a: information Related to information commands: (doc, help, information, reddit, site, tags) p: 2 - normal Normal Priority s: waiting for author Waiting for author to address a review or respond to a comment t: feature New feature or request labels Mar 1, 2020
@lemonsaurus lemonsaurus changed the title Removed API reliability for Tags Removed API dependency for Tags Mar 3, 2020

@lemonsaurus lemonsaurus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrite this to make full use of pathlib instead of leaning on the os module to solve most of the problems for you. we shouldn't need to import os at all for this file.

Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
RohanJnr added 2 commits March 4, 2020 23:30
The pathlib module simplifies opening and reading files, hence the os module and the context manager are no longer used.
"get_tags()" and "_get_tag()" functions need not be async as we are no longer doing any API call but instead reading from local files.
@MarkKoz

MarkKoz commented Mar 4, 2020

Copy link
Copy Markdown
Contributor

Hey @RohanJnr, recently more pre-commit hooks were added. I'm not sure if you don't have the pre-commit hook installed or if it just failed to update and include the new hooks for you. You may need to merge master first. CI is failing because the new hooks remove trailing whitespaces and ensure final newlines in files. Some of the tag markdown files you added have those issues. If you run pipenv run lint and commit the changes, it should fix all those issues.

@sco1

sco1 commented Mar 4, 2020

Copy link
Copy Markdown
Contributor

The new hooks have been merged & the tag files updated for the new linting. Please be sure to pull down the changes before making more commits, and ensure that your linting environment has been updated appropriately.

@lemonsaurus lemonsaurus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@MarkKoz MarkKoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there's only one command now, a command group is no longer necessary. Be mindful of existing aliases in alias.py when you go to remove the group.

Comment thread bot/cogs/tags.py Outdated
Comment thread bot/cogs/tags.py Outdated
@RohanJnr
RohanJnr requested a review from MarkKoz March 12, 2020 16:56
Comment thread bot/resources/tags/ytdl.md Outdated

For reference, this usage is covered by the following clauses in [YouTube's TOS](https://www.youtube.com/static?template=terms), as of 2019-07-22:
```
The following restrictions apply to your use of the Service. You are not allowed to:

@sco1 sco1 Mar 12, 2020

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why the language regarding redistribution was removed from this tag:

  1. access, reproduce, download, distribute, transmit, broadcast, display, sell, license, alter, modify or otherwise use any part of the Service or any Content except: (a) as expressly authorized by the Service; or (b) with prior written permission from YouTube and, if applicable, the respective rights holders;
  1. use the Service to view or listen to Content other than for personal, non-commercial use (for example, you may not publicly screen videos or stream music from the Service); or

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed it because it is just a side effect of youtube-dl, this tool in itself is only against 3rd paragraph, the first and 9th paragraph are about redistributibg the content created by tool such as youtube-dl, but aren't directly caused by it. For instance I could download my music collection using it and keep it on my computer, and it would only be against the 3rd paragraph.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The overwhelming majority of use cases encountered on our server utilize ytdl to stream content with a discord bot, which is redistributing content outside of YouTube’s platform. That is why these sections were all included and why they should remain in the tag.

Please ask questions on these things before unilaterally making a decision to remove them.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It just didn't made sense to me based on what was already in the tag.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added 1 & 9.

@MarkKoz MarkKoz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tag search command is broken:

AttributeError: 'Tags' object has no attribute '_get_tags'

As far as I can see, everything else is fine. Fix the above error and this PR should be good to go.

RohanJnr and others added 3 commits March 14, 2020 19:43
The tags have now been shifted from the database to being static files and hence the get_tags()
method has undergone changes. It now dosen't fetch from the database but looks at the local files
and we need not call it more than once.
* Add a constant for the footer text
* Import constants module rather than its classes
Comment thread bot/cogs/tags.py
RohanJnr and others added 4 commits March 15, 2020 17:05
Fixed `!tag search any` raises `AttributeError`.
Changed default value of `keywords` from `None` to `'any'`.
This will make it search for keyword `'any'` when there is no keyword.
@ikuyarihS
ikuyarihS merged commit 99c05dc into python-discord:master Mar 15, 2020
@Xithrius Xithrius removed the s: waiting for author Waiting for author to address a review or respond to a comment label May 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: information Related to information commands: (doc, help, information, reddit, site, tags) p: 2 - normal Normal Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tags overhaul

8 participants