8000 Sourcery refactored main branch by sourcery-ai[bot] · Pull Request #1 · jojo8356/Chocolate · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Sourcery refactored main branch #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Could not load branches
from
Open

Conversation

sourcery-ai[bot]
Copy link
@sourcery-ai sourcery-ai bot commented Sep 14, 2023

Branch main refactored by Sourcery.

If you're happy with these changes, merge this Pull Request using the Squash and merge strategy.

See our documentation here.

Run Sourcery locally

Reduce the feedback loop during development by using the Sourcery editor plugin:

Review changes via command line

To manually merge these changes, make sure you're on the main branch, then run:

git fetch origin sourcery/main
git merge --ff-only FETCH_HEAD
git reset HEAD^

Help us improve this pull request!

@sourcery-ai sourcery-ai bot requested a review from jojo8356 September 14, 2023 17:20
Comment on lines -66 to +69
self.name = name
if password != None:
self.password = generate_password_hash(password)
else:
self.password = None
self.profilePicture = profilePicture
self.accountType = accountType
self.name = name
self.password = generate_password_hash(password) if password != None else None
self.profilePicture = profilePicture
self.accountType = accountType
Copy link
Author

Choose a reason for hiding this comment

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

Function Users.__init__ refactored with the following changes:

Comment on lines -78 to +77
if self.password == None:
return True
return check_password_hash(self.password, pwd)
if self.password is None:
return True
return check_password_hash(self.password, pwd)
Copy link
Author

Choose a reason for hiding this comment

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

Function Users.verify_password refactored with the following changes:

Comment on lines -374 to +450
game["first_release_date"] = "Unknown"
if "cover" not in game:
game["cover"] = {"url": "//images.igdb.com/igdb/image/upload/t_cover_big/nocover.png"}

game["summary"] = translate(game["summary"])
game["genres"][0]["name"] = translate(game["genres"][0]["name"])


genres = []
for genre in game["genres"]:
genres.append(genre["name"])
genres = ", ".join(genres)

gameData = {
"title": game["name"], "cover": game["cover"]["url"].replace("//", "https://"), "description": game["summary"], "note": game["total_rating"], "date": game["first_release_date"], "genre": genres, "id": game["id"]
}
return gameData
except:
continue
return None
customHeaders = {
'User-Agent': 'Mozilla/5.0 (X11; UwUntu; Linux x86_64; rv:100.0) Gecko/20100101 Firefox/100.0',
'Accept': '*/*',
'X-Requested-With': 'XMLHttpRequest',
'Origin': url,
'DNT': '1',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'same-origin',
'Referer': url,
'Connection': 'keep-alive',
'Pragma': 'no-cache',
'Cache-Control': 'no-cache',
}
response = requests.request("GET", url, headers=customHeaders)

if response.status_code == 403:
return None
elif response.json() != {}:
grantType = "client_credentials"
getAccessToken = f"https://id.twitch.tv/oauth2/token?client_id={clientID}&client_secret={clientSecret}&grant_type={grantType}"
token = requests.request("POST", getAccessToken)
token = token.json()
token = token["access_token"]

headers = {
"Accept": "application/json", "Authorization": f"Bearer {token}", "Client-ID": clientID
}

games = response.json()["game_suggest"]
for i in games:
game=i
gameId = game["id"]
url = "https://api.igdb.com/v4/games"
body = f"fields name, cover.*, summary, total_rating, first_release_date, genres.*, platforms.*; where id = {gameId};"
response = requests.request("POST", url, headers=headers, data=body)
if len(response.json())==0:
break
game = response.json()[0]
if "platforms" in game:
gamePlatforms = game["platforms"]
try:
platforms = [i["abbreviation"] for i in gamePlatforms]

realConsoleName = {
"GB": "Game Boy", "GBA": "Game Boy Advance", "GBC": "Game Boy Color", "N64": "Nintendo 64", "NES": "Nintendo Entertainment System", "NDS": "Nintendo DS", "SNES": "Super Nintendo Entertainment System", "Sega Master System": "Sega Master System", "Sega Mega Drive": "Sega Mega Drive", "PS1": "PS1"
}

if realConsoleName[console] not in platforms and console not in platforms:
continue
if "total_rating" not in game:
game["total_rating"] = "Unknown"
if "genres" not in game:
game["genres"] = [{"name": "Unknown"}]
if "summary" not in game:
game["summary"] = "Unknown"
if "first_release_date" not in game:
game["first_release_date"] = "Unknown"
if "cover" not in game:
game["cover"] = {"url": "//images.igdb.com/igdb/image/upload/t_cover_big/nocover.png"}

game["summary"] = translate(game["summary"])
game["genres"][0]["name"] = translate(game["genres"][0]["name"])


genres = [genre["name"] for genre in game["genres"]]
genres = ", ".join(genres)

return {
"title": game["name"],
"cover": game["cover"]["url"].replace("//", "https://"),
"description": game["summary"],
"note": game["total_rating"],
"date": game["first_release_date"],
"genre": genres,
"id": game["id"],
}
except:
continue
return None
Copy link
Author

Choose a reason for hiding this comment

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

Function IGDBRequest refactored with the following changes:

Comment on lines -453 to +457
language = config["ChocolateSettings"]["language"]
if language == "EN":
return string
translated = GoogleTranslator(source='english', target=language.lower()).translate(string)
return translated
language = config["ChocolateSettings"]["language"]
if language == "EN":
return string
return GoogleTranslator(source='english',
target=language.lower()).translate(string)
Copy link
Author

Choose a reason for hiding this comment

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

Function translate refactored with the following changes:

CHUNK_LENGTH = int(CHUNK_LENGTH)
CHUNK_LENGTH = CHUNK_LENGTH
Copy link
Author

Choose a reason for hiding this comment

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

Lines 506-506 refactored with the following changes:


Copy link
Author

Choose a reason for hiding this comment

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

Function detectIntro refactored with the following changes:

This removes the following comments ( why? ):

# if both are 0.0, then it's not set
# if introEnd is 0.0, then it's not set
# if introStart is 0.0, then it's not set

8000 Comment on lines -256 to +261
episodes = []
for episode in os.listdir(seasonPath):
if episode.endswith(".mp4") or episode.endswith(".mkv") or episode.endswith(".avi") or episode.endswith(".mov") or episode.endswith(".wmv"):
episodes.append(episode)
return episodes
return [
episode
for episode in os.listdir(seasonPath)
if episode.endswith(".mp4")
or episode.endswith(".mkv")
or episode.endswith(".avi")
or episode.endswith(".mov")
or episode.endswith(".wmv")
]
Copy link
Author

Choose a reason for hiding this comment

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

Function listAllVideoFiles refactored with the following changes:

Comment on lines -305 to +310
for compare_element in allIndexes:
if compare_element - element <= 4:
indexes.append(compare_element)

indexes.extend(
compare_element
for compare_element in allIndexes
if compare_element - element <= 4
)
Copy link
Author

Choose a reason for hiding this comment

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

Function compare_audio refactored with the following changes:

Comment on lines -315 to +318
audio_file_1 = os.path.splitext(video_file_1)[0] + ".wav"
audio_file_2 = os.path.splitext(video_file_2)[0] + ".wav"
audio_file_1 = f"{os.path.splitext(video_file_1)[0]}.wav"
audio_file_2 = f"{os.path.splitext(video_file_2)[0]}.wav"
Copy link
Author

Choose a reason for hiding this comment

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

Function main refactored with the following changes:

Comment on lines -331 to +334
if not useImage:
with app.app_context():
with app.app_context():
if not useImage:
Copy link
Author

Choose a reason for hiding this comment

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

Lines 331-352 refactored with the following changes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants
0