Skip to content

Commit

Permalink
made the readme "better"
Browse files Browse the repository at this point in the history
  • Loading branch information
PlOszukiwaczDEV committed Aug 8, 2024
1 parent f06bf2f commit 588bec3
Show file tree
Hide file tree
Showing 10 changed files with 198 additions and 39 deletions.
136 changes: 136 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
################### Python

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down Expand Up @@ -158,3 +160,137 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/


################### NodeJS

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
32 changes: 31 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
# lyrntpy
A api wrapper for lyrnt`s api in python

# How to make the .env file
In order to create a `.env` file you need 3 cookies:
- `_TOKEN_DO_NOT_SHARE`
- `temp-discord-token`
- `cf_clearance`

The `_TOKEN_DO_NOT_SHARE` cookie is required to authenticate with the lyrnt api.

The `temp-discord-token` cookie is only needed when creating an account (to my knowledge) so it can probaly left empty but i would stil set it.

The `cf_clearance` is used to authenticate with cloudflare and use the api and not be blocked. This cookie is known for expirering quickly, for now the
solution is to manualy copy the cookie from a browser and paste it it (i am working on an automatic system).

Now that we know what each cookie does, how to actually get them? (please note the tutorial for getting the cookies is for firefox)

Firstly navigate to [lyrnt](https://lyrnt.com) and press `Control+S+I`, you should be meet with this
![devtools open](readme_images/devtools1.png)

Now navigate to the `Storage` tab
![devtools storage tab](readme_images/devtools2.png)

And click on `Cookies > https://lyntr.com`
![devtools cookies tab open](readme_images/devtools3.png)

Now copy the `_TOKEN_DO_NOT_SHARE` cookie to the file `.env` to a variable named `TOKEN`, the `temp-discord-token` cookie to `temp-discord-token` and the `cf_clearance` cookie to `cf_clearance`.

If you do all these steps correctly you should be able to start implementing the wrapper in your code.

Happy Codeing.

# ToDo
- [ ] Add photo support for lynting
- [ ] Add auto login so manual pasting cookies from browser to .env is not required
- [ ] Add auto cloudflare cookies collector from browser to .env is not required
3 changes: 3 additions & 0 deletions lynt.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,6 @@ def get_lynt(lyntID : int):
def get_comments_lynt(lyntID : int):
r = requests.get(f"https://lyntr.com/api/comments?id={lyntID}", cookies=cookies, headers=utils.headers.get_lynt_headers)
return r
def search_lynts(search):
r = requests.get(f"https://lyntr.com/api/search?q={search}", cookies=cookies, headers=utils.headers.search_headers)
return r
Binary file added readme_images/devtools1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_images/devtools2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added readme_images/devtools3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
python-dotenv
requests
cloudscraper
requests
20 changes: 11 additions & 9 deletions profilee.py → user.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,15 @@
'cf_clearance': os.getenv('cf_clearance'),
}

def get_profile(profileHandle):
def edit_profile(username : str = None, bio : str = "Nothing here yet..."):
data = {
'bio': bio,
'username': username
}

r = requests.patch('https://lyntr.com/api/profile', cookies=cookies, headers=utils.headers.profile_headers, data=data)
return r
def get_user_profile(profileHandle):
"""
Get a profile via thier handle
"""
Expand All @@ -25,11 +33,5 @@ def get_profile(profileHandle):

r = requests.get('https://lyntr.com/api/profile', params=params, cookies=cookies, headers=utils.headers.profile_headers)
return r
def edit_profile(username : str = None, bio : str = "Nothing here yet..."):
data = {
'bio': bio,
'username': username
}

r = requests.patch('https://lyntr.com/api/profile', cookies=cookies, headers=utils.headers.profile_headers, data=data)
return r
def delete_user():
pass
27 changes: 0 additions & 27 deletions utils/cf_cookie.py

This file was deleted.

16 changes: 16 additions & 0 deletions utils/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,19 @@
# Requests doesn't support trailers
# 'TE': 'trailers',
}
search_headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; rv:128.0) Gecko/20100101 Firefox/128.0',
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
# 'Accept-Encoding': 'gzip, deflate, br, zstd',
'Referer': 'https://lyntr.com/api/search?q=!ai',
'DNT': '1',
'Connection': 'keep-alive',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Sec-GPC': '1',
'Priority': 'u=0',
# Requests doesn't support trailers
# 'TE': 'trailers',
}

0 comments on commit 588bec3

Please sign in to comment.