Skip to content
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

feat: 剧集api开发完成 #1

Merged
merged 1 commit into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Github的token
GH_TOKEN=XX
#turso服务的url
TURSO_DB_URL=XX
#turso服务的认证token
TURSO_DB_AUTH_TOKEN=XX
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "weekly"
allow:
- dependency-name: "Flask"
- dependency-name: "libsql_client"
44 changes: 44 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
version-template: $MAJOR.$MINOR.$PATCH
# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: '✨ Features'
labels:
- 'feat'
- 'feature'
- 'enhancement'
- 'kind/feature'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'regression'
- 'kind/bug'
- title: 📝 Documentation updates
labels:
- 'documentation'
- 'kind/doc'
- 'doc'
- title: 👻 Maintenance
labels:
- 'chore'
- 'dependencies'
- 'kind/chore'
- 'kind/dep'
- title: ⚡️ Tests
labels:
- 'test'
- 'tests'
exclude-labels:
- 'reverted'
- 'no-changelog'
- 'skip-changelog'
- 'invalid'
change-template: '* $TITLE (#$NUMBER) @$AUTHOR'
change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
template: |
## What’s Changed
$CHANGES
24 changes: 24 additions & 0 deletions .github/workflows/update_release_draft.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: update_release_draft.yml

on:
push:
branches:
- main
pull_request:

types: [ opened, reopened, synchronize ]

permissions:
contents: write
packages: write

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3 changes: 3 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions .vscode/launch.json

This file was deleted.

3 changes: 0 additions & 3 deletions .vscode/settings.json

This file was deleted.

177 changes: 116 additions & 61 deletions components/trakt/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,95 +5,150 @@
# 创建蓝图
blueprint = Blueprint('trakt', __name__, url_prefix='/trakt')


# =========================电影================================


@blueprint.route('/movie')
def movies():
"""分页获取电影列表
"""分页获取电影列表

Returns:
_type_: 电影列表
"""
# 获取请求参数page和page_size
curr_page = int(request.args.get('page', 1))
page_size = int(request.args.get('page_size', 10))
try:
return Result.success(movie_handler.get_movies(curr_page, page_size))
except Exception as e:
return Result.fail(e)
Returns:
_type_: 电影列表
"""
# 获取请求参数page和page_size
curr_page = int(request.args.get('page', 1))
page_size = int(request.args.get('page_size', 10))
try:
return Result.success(movie_handler.get_movies(curr_page, page_size))
except Exception as e:
return Result.fail(e)


@blueprint.route('/movie/<movie_id>')
def movie(movie_id):
"""获取电影详情
"""获取电影详情

Args:
movie_id (str): 电影的tmdb_id
Args:
movie_id (str): 电影的tmdb_id

Returns:
_type_: 电影详情
"""
try:
return Result.success(movie_handler.get_movie(movie_id))
except Exception as e:
return Result.fail(e)
Returns:
_type_: 电影详情
"""
try:
return Result.success(movie_handler.get_movie(movie_id))
except Exception as e:
return Result.fail(e)


@blueprint.route('/update_movie_share_link', methods=['POST'])
def update_movie_share_link():
"""更新电影分享链接 content-type为application/x-www-form-urlencoded

Returns:
_type_: 更新结果
"""
# 获取请求参数tmdb_id和share_link
movie_id = request.form.get('movie_id')
share_link = request.form.get('share_link')
if not movie_id or not share_link:
return Result.fail('movie_id和share_link不能为空')
try:
movie_handler.update_share_link(movie_id, share_link)
return Result.success('更新成功')
except Exception as e:
return Result.fail(e)
"""更新电影分享链接 content-type为application/x-www-form-urlencoded

Returns:
_type_: 更新结果
"""
# 获取请求参数tmdb_id和share_link
movie_id = request.form.get('movie_id')
share_link = request.form.get('share_link')
if not movie_id or not share_link:
return Result.fail('movie_id和share_link不能为空')
try:
movie_handler.update_share_link(movie_id, share_link)
return Result.success('更新成功')
except Exception as e:
return Result.fail(e)


# ==============================剧集===================================


@blueprint.route('/show')
def shows():
"""分页获取剧集列表

Returns:
_type_: 剧集列表
"""
# 获取请求参数page和page_size
curr_page = int(request.args.get('page', 1))
page_size = int(request.args.get('page_size', 10))
try:
return Result.success(show_handler.get_shows(curr_page, page_size))
except Exception as e:
return Result.fail(e)


@blueprint.route('/show/<show_id>')
def show(show_id):
"""获取剧集详情

Args:
show_id (str): 剧集的tmdb_id

Returns:
_type_: 剧集详情
"""
try:
return Result.success(show_handler.get_show(show_id))
except Exception as e:
return Result.fail(e)


@blueprint.route('/update_show_share_link', methods=['POST'])
def update_show_share_link():
"""更新剧集分享链接 content-type为application/x-www-form-urlencoded

Returns:
_type_: 更新结果
"""
# 获取请求参数tmdb_id和share_link
show_id = request.form.get('show_id')
share_link = request.form.get('share_link')
if not show_id or not share_link:
return Result.fail('show_id和share_link不能为空')
try:
show_handler.update_share_link(show_id, share_link)
return Result.success('更新成功')
except Exception as e:
return Result.fail(e)


# ==============================common================================


@blueprint.route('/index')
def index():
"""获取电影/剧集索引
"""
try:
return Result.success({
'movie': movie_handler.get_index(),
'show': show_handler.get_index()
})
except Exception as e:
return Result.fail(e)
"""获取电影/剧集索引
"""
try:
return Result.success({
'movie': movie_handler.get_index(),
'show': show_handler.get_index()
})
except Exception as e:
return Result.fail(e)


@blueprint.route('/refresh_movie_cache')
def refresh_movie_cache():
"""刷新电影缓存
"""
try:
movie_handler.get_movies.cache_clear()
movie_handler.get_movie.cache_clear()
movie_handler.get_index.cache_clear()
return Result.success(msg='刷新movie缓存成功')
except Exception as e:
return Result.fail(e)
"""刷新电影缓存
"""
try:
movie_handler.get_movies.cache_clear()
movie_handler.get_movie.cache_clear()
movie_handler.get_index.cache_clear()
return Result.success(msg='刷新movie缓存成功')
except Exception as e:
return Result.fail(e)


@blueprint.route('/refresh_show_cache')
def refresh_show_cache():
"""刷新剧集缓存
"""
try:
show_handler.get_index.cache_clear()
return Result.success(msg='刷新show缓存成功')
except Exception as e:
return Result.fail(e)
"""刷新剧集缓存
"""
try:
show_handler.get_index.cache_clear()
return Result.success(msg='刷新show缓存成功')
except Exception as e:
return Result.fail(e)
Loading
Loading