├── .dockerignore ├── .gitignore ├── .vscode └── settings.json ├── LICENSE ├── README.md ├── README_CN.md ├── app ├── [lang] │ ├── (default) │ │ ├── _components │ │ │ ├── footer │ │ │ │ └── index.tsx │ │ │ ├── header │ │ │ │ └── index.tsx │ │ │ ├── hero │ │ │ │ └── index.tsx │ │ │ ├── input │ │ │ │ └── index.tsx │ │ │ ├── langswitch │ │ │ │ └── index.tsx │ │ │ ├── producthunt │ │ │ │ └── index.tsx │ │ │ ├── social │ │ │ │ └── index.tsx │ │ │ ├── tab │ │ │ │ └── index.tsx │ │ │ └── videos │ │ │ │ └── index.tsx │ │ ├── layout.tsx │ │ ├── page.tsx │ │ ├── video │ │ │ └── [uuid] │ │ │ │ └── page.tsx │ │ └── videos │ │ │ └── [cate] │ │ │ └── page.tsx │ ├── globals.css │ └── layout.tsx └── api │ ├── gen-video │ └── route.ts │ ├── process │ └── update-videos │ │ └── route.ts │ └── save-user │ └── route.ts ├── components.json ├── components └── ui │ ├── menubar.tsx │ └── select.tsx ├── data └── install.sql ├── debug └── apitest.http ├── deploy ├── Dockerfile └── nginx.conf ├── dictionaries ├── de.json ├── en.json ├── fr.json ├── ja.json ├── ko.json └── zh.json ├── lib ├── index.ts ├── resp.ts └── utils.ts ├── middleware.ts ├── models ├── db.ts ├── user.ts └── video.ts ├── next.config.mjs ├── package-lock.json ├── package.json ├── pnpm-lock.yaml ├── postcss.config.js ├── preview.png ├── preview_cn.png ├── public ├── email.svg ├── favicon.ico ├── next.svg └── vercel.svg ├── services ├── i18n.ts ├── user.ts └── video.ts ├── tailwind.config.ts ├── tsconfig.json └── types ├── nav.d.ts ├── user.d.ts └── video.d.ts /.dockerignore: -------------------------------------------------------------------------------- 1 | .next 2 | .vercel 3 | .vscode 4 | data 5 | debug 6 | node_modules -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | .yarn/install-state.gz 8 | 9 | # testing 10 | /coverage 11 | 12 | # next.js 13 | /.next/ 14 | /out/ 15 | 16 | # production 17 | /build 18 | 19 | # misc 20 | .DS_Store 21 | *.pem 22 | 23 | # debug 24 | npm-debug.log* 25 | yarn-debug.log* 26 | yarn-error.log* 27 | 28 | # local env files 29 | .env* 30 | Makefile 31 | data/data.json 32 | 33 | # vercel 34 | .vercel 35 | 36 | # typescript 37 | *.tsbuildinfo 38 | next-env.d.ts 39 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.defaultFormatter": "esbenp.prettier-vscode", 3 | "[javascript]": { 4 | "editor.defaultFormatter": "esbenp.prettier-vscode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sora.FM 2 | 3 | Sora AI Video Generator 4 | 5 | > Sora text-to-video API is not available. All the videos display on Sora.FM are generated by OpenAI's red team. 6 | 7 | [中文说明](./README_CN.md) 8 | 9 | ## Live Demo 10 | 11 | [https://sorafm.trys.ai](https://sorafm.trys.ai) 12 | 13 | ![preview](./preview.png) 14 | 15 | ## Deploy with Vercel 16 | 17 | [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fall-in-aigc%2Fsorafm&env=POSTGRES_URL,WEB_BASE_URI&envDescription=POSTGRES_URL%20needed%20for%20the%20application&project-name=my-sora-project&repository-name=my-sora-project&redirect-url=https%3A%2F%2Fsorafm.trys.ai&demo-title=Sora.FM&demo-description=Sora%20AI%20Video%20generator&demo-url=https%3A%2F%2Fsorafm.trys.ai&demo-image=https%3A%2F%2Fgithub.com%2Fall-in-aigc%2Fsorafm%2Fraw%2Fmain%2Fpreview.png) 18 | 19 | ## Deploy with docker 20 | 21 | - build image 22 | 23 | ```shell 24 | sudo docker build -f deploy/Dockerfile -t sorafm:latest . 25 | ``` 26 | 27 | - run server 28 | 29 | ```shell 30 | sudo docker run -itd -p 127.0.0.1:8014:8080 --restart=always sorafm:latest 31 | ``` 32 | 33 | - nginx conf 34 | 35 | ```txt 36 | server { 37 | listen 80; 38 | 39 | location / { 40 | proxy_pass http://127.0.0.1:8014/; 41 | proxy_set_header Host $http_host; 42 | proxy_set_header X-Real-IP $remote_addr; 43 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 44 | proxy_set_header X-Forwarded-Proto $scheme; 45 | } 46 | 47 | error_log /var/log/nginx/sorafm.error; 48 | } 49 | ``` 50 | 51 | ## Local development 52 | 53 | 1. clone project 54 | 55 | ```shell 56 | git clone https://github.com/all-in-aigc/sorafm 57 | ``` 58 | 59 | 2. install dependencies 60 | 61 | ```shell 62 | cd sorafm 63 | pnpm install 64 | ``` 65 | 66 | 3. init database 67 | 68 | create your database use [local postgres](https://wiki.postgresql.org/wiki/Homebrew) or [vercel-postgres](https://vercel.com/docs/storage/vercel-postgres) or [supabase](https://supabase.com/) 69 | 70 | create tables from sql at `data/install.sql` 71 | 72 | 4. set environmental values 73 | 74 | put `.env.local` under root dir with values list below 75 | 76 | ``` 77 | POSTGRES_URL="postgres://USER:PASSWORD@HOST/DB" 78 | 79 | WEB_BASE_URI="http://localhost:3000" 80 | ``` 81 | 82 | 5. local development 83 | 84 | ```shell 85 | pnpm dev --port 3000 86 | ``` 87 | 88 | open `http://localhost:3000` for preview 89 | 90 | ## Credit to 91 | 92 | - [aiwallpaper](https://aiwallpaper.shop) for code reference 93 | - [nextjs](https://nextjs.org/docs) for full-stack development 94 | - [node-postgres](https://node-postgres.com/) for data processing 95 | - [tailwindcss](https://tailwindcss.com/) for page building 96 | 97 | ## Other Things 98 | 99 | you can contact me at Twitter: https://twitter.com/idoubicc 100 | 101 | if this project is helpful to you, buy be a coffee. 102 | 103 | Buy Me A Coffee 104 | 105 | ## Star History 106 | 107 | [![Star History Chart](https://api.star-history.com/svg?repos=all-in-aigc/sorafm&type=Date)](https://star-history.com/#all-in-aigc/sorafm&Date) 108 | -------------------------------------------------------------------------------- /README_CN.md: -------------------------------------------------------------------------------- 1 | # Sora.FM 2 | 3 | Sora AI 视频生成器 4 | 5 | > Sora 文本生成视频 API 还未发布,网站上展示的所有视频都是由 OpenAI 官方生成的。 6 | 7 | ## 线上演示 8 | 9 | [https://sora.trys.ai](https://sora.trys.ai) 10 | 11 | ![preview](./preview_cn.png) 12 | 13 | ## 使用 Vercel 一键部署 14 | 15 | [![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fall-in-aigc%2Fsorafm&env=POSTGRES_URL,WEB_BASE_URI&envDescription=POSTGRES_URL%20needed%20for%20the%20application&project-name=my-sora-project&repository-name=my-sora-project&redirect-url=https%3A%2F%2Fsora.trys.ai&demo-title=Sora.FM&demo-description=Sora%20AI%20Video%20generator&demo-url=https%3A%2F%2Fsora.trys.ai&demo-image=https%3A%2F%2Fgithub.com%2Fall-in-aigc%2Fsorafm%2Fraw%2Fmain%2Fpreview.png) 16 | 17 | ## 使用 Docker 部署 18 | 19 | - 构建镜像 20 | 21 | ```shell 22 | sudo docker build -f deploy/Dockerfile -t sorafm:latest . 23 | ``` 24 | 25 | - 运行服务 26 | 27 | ```shell 28 | sudo docker run -itd -p 127.0.0.1:8014:8080 --restart=always sorafm:latest 29 | ``` 30 | 31 | - 配置 nginx 32 | 33 | ```txt 34 | server { 35 | listen 80; 36 | 37 | location / { 38 | proxy_pass http://127.0.0.1:8014/; 39 | proxy_set_header Host $http_host; 40 | proxy_set_header X-Real-IP $remote_addr; 41 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 42 | proxy_set_header X-Forwarded-Proto $scheme; 43 | } 44 | 45 | error_log /var/log/nginx/sorafm.error; 46 | } 47 | ``` 48 | 49 | ## 本地开发 50 | 51 | 1. 克隆项目 52 | 53 | ```shell 54 | git clone https://github.com/all-in-aigc/sorafm 55 | ``` 56 | 57 | 2. 安装依赖 58 | 59 | ```shell 60 | cd sorafm 61 | pnpm install 62 | ``` 63 | 64 | 3. 初始化数据库 65 | 66 | 使用本地的 [local postgres](https://wiki.postgresql.org/wiki/Homebrew) 或者托管的 [vercel-postgres](https://vercel.com/docs/storage/vercel-postgres) 或者 [supabase](https://supabase.com/) 67 | 68 | 使用 `data/install.sql` 文件里的建表语句创建数据表。 69 | 70 | 4. 设置环境变量 71 | 72 | 在项目根目录创建 `.env.local` 文件,写入如下配置: 73 | 74 | ``` 75 | POSTGRES_URL="postgres://USER:PASSWORD@HOST/DB" 76 | 77 | WEB_BASE_URI="http://localhost:3000" 78 | ``` 79 | 80 | 5. 本地开发 81 | 82 | ```shell 83 | pnpm dev --port 3000 84 | ``` 85 | 86 | 打开 `http://localhost:3000` 预览 87 | 88 | ## 致谢以下项目 89 | 90 | - [aiwallpaper](https://aiwallpaper.shop) 提供代码参考 91 | - [nextjs](https://nextjs.org/docs) 全栈开发框架 92 | - [node-postgres](https://node-postgres.com/) 数据处理库 93 | - [tailwindcss](https://tailwindcss.com/) 页面构建 94 | 95 | ## 其他 96 | 97 | > 如果你想学习全栈开发,实现类似的产品,你可以参加我的 [全栈开发课程](https://mp.weixin.qq.com/s/4duIpeZkmqlKPa4jrcUdIA) 98 | 99 | 你可以在 Twitter 上联系我: https://twitter.com/idoubicc 100 | 101 | 或者关注我的微信公众号 👇 102 | 103 | 104 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/footer/index.tsx: -------------------------------------------------------------------------------- 1 | import Social from "../social"; 2 | 3 | export default function ({ lang, dict }: { lang: string; dict: any }) { 4 | return ( 5 |
6 |
7 |
8 |
9 | 10 | Sora.FM 11 | 12 |

13 | {dict.brand.title} 14 |

15 |
16 | 17 |
18 |
19 |
20 |
21 |
INTRODUCTION
22 | 27 | What's Sora 28 | 29 | 34 | Sora technical report 35 | 36 | 41 | Sora API 42 | 43 | 48 | Sora Showcases 49 | 50 | 55 | Sora Prompts 56 | 57 |
58 |
59 |
FRIENDS
60 | 65 | GPTs Works 66 | 67 | 72 | GPTalk 73 | 74 | 79 | AI Wallpaper 80 | 81 | 86 | AI Cover 87 | 88 | 93 | ReadKnown 94 | 95 |
96 |
97 |
CREDIT TO
98 | 103 | Sora.FM 104 | 105 | 110 | Stable Video 111 | 112 | 117 | Pika 118 | 119 | 124 | Gen-2 125 | 126 |
127 | {lang.startsWith("zh") && ( 128 |
129 |
130 |

131 |

132 | qrcode 141 |

142 |
143 |
144 | )} 145 |
146 |
147 |
148 |
149 |

150 | © Copyright 2024.{" "} 151 | 156 | Sora.FM 157 | {" "} 158 | All rights reserved. 159 |

160 |
161 |
162 |
163 | ); 164 | } 165 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/header/index.tsx: -------------------------------------------------------------------------------- 1 | import Langswitch from "../langswitch"; 2 | import { Nav } from "@/types/nav"; 3 | import Social from "../social"; 4 | 5 | export default function ({ lang, dict }: { lang: string; dict: any }) { 6 | const navigations: Nav[] = []; 7 | 8 | return ( 9 |
10 |
11 | 48 |
49 |
50 | ); 51 | } 52 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/hero/index.tsx: -------------------------------------------------------------------------------- 1 | import Input from "../input"; 2 | import Producthunt from "../producthunt"; 3 | 4 | export default function ({ dict }: { dict: any }) { 5 | return ( 6 |
7 |
8 |

9 | {dict.brand.title} 10 |

11 |

12 | {dict.brand.sub_title} 13 |

14 | 15 | 16 | 17 | 18 | 19 |
20 | {dict.subscribe.tip} 21 |
22 | 23 | 49 |
50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/input/index.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { KeyboardEvent, useState } from "react"; 4 | import { useParams, useRouter } from "next/navigation"; 5 | 6 | import { toast } from "sonner"; 7 | 8 | export default function ({ dict }: { dict: any }) { 9 | const params = useParams(); 10 | 11 | const router = useRouter(); 12 | const [email, setEmail] = useState(""); 13 | 14 | const handleSubmit = async () => { 15 | if (!email) { 16 | toast.error("please enter your email"); 17 | return; 18 | } 19 | 20 | try { 21 | const params = { 22 | email: email, 23 | }; 24 | const resp = await fetch("/api/save-user", { 25 | method: "POST", 26 | headers: { 27 | "Content-Type": "application/json", 28 | }, 29 | body: JSON.stringify(params), 30 | }); 31 | const { code, message, data } = await resp.json(); 32 | if (code !== 0) { 33 | toast.error(message); 34 | return; 35 | } 36 | if (data) { 37 | toast.success("subscribe ok"); 38 | setEmail(""); 39 | } 40 | } catch (e) { 41 | toast.error("subscribe failed"); 42 | console.log("subscribe failed", e); 43 | } 44 | }; 45 | 46 | const handleInputKeydown = (e: KeyboardEvent) => { 47 | if (e.code === "Enter" && !e.shiftKey) { 48 | if (e.keyCode !== 229) { 49 | e.preventDefault(); 50 | handleSubmit(); 51 | } 52 | } 53 | }; 54 | 55 | return ( 56 |
57 | setEmail(e.target.value)} 64 | onKeyDown={handleInputKeydown} 65 | /> 66 | 73 |
74 | ); 75 | } 76 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/langswitch/index.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { 4 | Select, 5 | SelectContent, 6 | SelectItem, 7 | SelectTrigger, 8 | SelectValue, 9 | } from "@/components/ui/select"; 10 | import { useParams, usePathname, useRouter } from "next/navigation"; 11 | 12 | import { localeNames } from "@/services/i18n"; 13 | 14 | export default function () { 15 | const params = useParams(); 16 | const lang = params.lang as string; 17 | const router = useRouter(); 18 | const pathname = usePathname(); 19 | 20 | const handleSwitchLanguage = (value: string) => { 21 | if (value !== "lang") { 22 | const newPathName = pathname.replace(lang, value); 23 | router.push(newPathName); 24 | } 25 | }; 26 | 27 | return ( 28 | 43 | ); 44 | } 45 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/producthunt/index.tsx: -------------------------------------------------------------------------------- 1 | export default function () { 2 | return ( 3 |
4 | 8 | Sora AI Video Generator - OpenSourced web template for Sora AI Video generating | Product Hunt 14 | 15 |
16 | ); 17 | } 18 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/social/index.tsx: -------------------------------------------------------------------------------- 1 | "use client"; 2 | 3 | import { BsBook, BsGithub, BsTwitterX } from "react-icons/bs"; 4 | 5 | import { FaProductHunt } from "react-icons/fa"; 6 | import { SiBuymeacoffee } from "react-icons/si"; 7 | import { useParams } from "next/navigation"; 8 | 9 | export default function () { 10 | const params = useParams(); 11 | const lang = params.lang as string; 12 | 13 | return ( 14 |
15 | 20 | 21 | 22 | 27 | 28 | 29 | 34 | 35 | 36 | 41 | 42 | 43 | {lang.startsWith("zh") && ( 44 | 49 | 50 | 51 | )} 52 |
53 | ); 54 | } 55 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/tab/index.tsx: -------------------------------------------------------------------------------- 1 | function classNames(...classes: string[]) { 2 | return classes.filter(Boolean).join(" "); 3 | } 4 | 5 | export default function ({ 6 | lang, 7 | dict, 8 | cate, 9 | }: { 10 | lang: string; 11 | dict: any; 12 | cate: string; 13 | }) { 14 | const tabs = [ 15 | { 16 | name: dict.tab.latest, 17 | href: `/${lang}/videos/latest`, 18 | current: cate === "" || cate === "latest", 19 | }, 20 | { 21 | name: dict.tab.featured, 22 | href: `/${lang}/videos/featured`, 23 | current: cate === "featured", 24 | }, 25 | { 26 | name: dict.tab.random, 27 | href: `/${lang}/videos/random`, 28 | current: cate === "random", 29 | }, 30 | ]; 31 | 32 | return ( 33 |
34 |
35 |
36 | 56 |
57 |
58 |
59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /app/[lang]/(default)/_components/videos/index.tsx: -------------------------------------------------------------------------------- 1 | import { Video } from "@/types/video"; 2 | 3 | export default ({ lang, videos }: { lang: string; videos: Video[] }) => { 4 | return ( 5 |
6 |
7 |
8 | {videos.map((video: Video, idx: number) => { 9 | return ( 10 |
11 | 12 |
13 | 25 | 26 |
27 | {video.user_nickname} 32 |

33 | {video.user_nickname} 34 |

35 |
36 | 37 |

38 | {video.video_description} 39 |

40 | 41 |
42 |
43 | 44 |

45 |
46 |
47 |
48 |
49 | ); 50 | })} 51 |
52 |
53 |
54 | ); 55 | }; 56 | -------------------------------------------------------------------------------- /app/[lang]/(default)/layout.tsx: -------------------------------------------------------------------------------- 1 | import Footer from "./_components/footer"; 2 | import Header from "./_components/header"; 3 | import { ReactNode } from "react"; 4 | import { getDictionary } from "@/services/i18n"; 5 | 6 | export default async function ({ 7 | children, 8 | params, 9 | }: { 10 | children: ReactNode; 11 | params: { lang: string }; 12 | }) { 13 | const dict = await getDictionary(params.lang); 14 | 15 | return ( 16 |
17 |
18 |
{children}
19 |
20 |
21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /app/[lang]/(default)/page.tsx: -------------------------------------------------------------------------------- 1 | import Hero from "./_components/hero"; 2 | import { Metadata } from "next"; 3 | import Tab from "./_components/tab"; 4 | import Videos from "./_components/videos"; 5 | import { getDictionary } from "@/services/i18n"; 6 | import { getLatestVideos } from "@/models/video"; 7 | 8 | export async function generateMetadata({ 9 | params, 10 | }: { 11 | params: { lang: string }; 12 | }): Promise { 13 | return { 14 | alternates: { 15 | canonical: `${process.env.WEB_BASE_URI}/${params.lang}`, 16 | }, 17 | }; 18 | } 19 | 20 | export default async function ({ params }: { params: { lang: string } }) { 21 | const videos = await getLatestVideos(1, 50); 22 | const dict = await getDictionary(params.lang); 23 | 24 | return ( 25 |
26 | 27 | 28 | 29 |
30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /app/[lang]/(default)/video/[uuid]/page.tsx: -------------------------------------------------------------------------------- 1 | import { findVideoByUuid, getRandomVideos } from "@/models/video"; 2 | 3 | import { Metadata } from "next"; 4 | import Videos from "../../_components/videos"; 5 | import { getDictionary } from "@/services/i18n"; 6 | 7 | export async function generateMetadata({ 8 | params, 9 | }: { 10 | params: { lang: string; uuid: string }; 11 | }): Promise { 12 | const dict = await getDictionary(params.lang); 13 | 14 | let description = ""; 15 | 16 | if (params.uuid) { 17 | const video = await findVideoByUuid(params.uuid); 18 | if (video) { 19 | description = video.video_description; 20 | } 21 | } 22 | 23 | return { 24 | description: `${description} ${dict.brand.title} | Sora.FM`, 25 | alternates: { 26 | canonical: `${process.env.WEB_BASE_URI}/${params.lang}/video/${params.uuid}`, 27 | }, 28 | }; 29 | } 30 | 31 | export default async function ({ 32 | params, 33 | }: { 34 | params: { lang: string; uuid: string }; 35 | }) { 36 | const dict = await getDictionary(params.lang); 37 | const video = await findVideoByUuid(params.uuid); 38 | const videos = await getRandomVideos(1, 50); 39 | 40 | return ( 41 |
42 |
43 |

44 | {dict.showcase.title} 45 |

46 |

47 | {dict.showcase.sub_title} 48 |

49 | 50 | {video && ( 51 |
52 | 114 | )} 115 |
116 | 117 |
118 |

119 | {dict.showcase.more_tip} 120 |

121 | 122 | 123 |
124 |
125 | ); 126 | } 127 | -------------------------------------------------------------------------------- /app/[lang]/(default)/videos/[cate]/page.tsx: -------------------------------------------------------------------------------- 1 | import { 2 | getLatestVideos, 3 | getRandomVideos, 4 | getRecommendedVideos, 5 | } from "@/models/video"; 6 | 7 | import Hero from "../../_components/hero"; 8 | import { Metadata } from "next"; 9 | import Tab from "../../_components/tab"; 10 | import { Video } from "@/types/video"; 11 | import Videos from "../../_components/videos"; 12 | import { getDictionary } from "@/services/i18n"; 13 | 14 | export async function generateMetadata({ 15 | params, 16 | }: { 17 | params: { lang: string; cate: string }; 18 | }): Promise { 19 | return { 20 | alternates: { 21 | canonical: `${process.env.WEB_BASE_URI}/${params.lang}/videos/${params.cate}`, 22 | }, 23 | }; 24 | } 25 | 26 | export default async function ({ 27 | params, 28 | }: { 29 | params: { lang: string; cate: string }; 30 | }) { 31 | const cate = params.cate; 32 | const page = 1; 33 | const limit = 50; 34 | const dict = await getDictionary(params.lang); 35 | 36 | let videos: Video[] = []; 37 | if (cate === "featured") { 38 | videos = await getRecommendedVideos(page, limit); 39 | } else if (cate === "random") { 40 | videos = await getRandomVideos(page, limit); 41 | } else { 42 | videos = await getLatestVideos(page, limit); 43 | } 44 | 45 | return ( 46 |
47 | 48 | 49 | 50 |
51 | ); 52 | } 53 | -------------------------------------------------------------------------------- /app/[lang]/globals.css: -------------------------------------------------------------------------------- 1 | @tailwind base; 2 | @tailwind components; 3 | @tailwind utilities; 4 | 5 | @layer base { 6 | :root { 7 | --background: 0 0% 100%; 8 | --foreground: 20 14.3% 4.1%; 9 | --card: 0 0% 100%; 10 | --card-foreground: 20 14.3% 4.1%; 11 | --popover: 0 0% 100%; 12 | --popover-foreground: 20 14.3% 4.1%; 13 | --primary: 24.6 95% 53.1%; 14 | --primary-foreground: 60 9.1% 97.8%; 15 | --secondary: 60 4.8% 95.9%; 16 | --secondary-foreground: 24 9.8% 10%; 17 | --muted: 60 4.8% 95.9%; 18 | --muted-foreground: 25 5.3% 44.7%; 19 | --accent: 60 4.8% 95.9%; 20 | --accent-foreground: 24 9.8% 10%; 21 | --destructive: 0 84.2% 60.2%; 22 | --destructive-foreground: 60 9.1% 97.8%; 23 | --border: 20 5.9% 90%; 24 | --input: 20 5.9% 90%; 25 | --ring: 24.6 95% 53.1%; 26 | --radius: 0.5rem; 27 | } 28 | 29 | .dark { 30 | --background: 20 14.3% 4.1%; 31 | --foreground: 60 9.1% 97.8%; 32 | --card: 20 14.3% 4.1%; 33 | --card-foreground: 60 9.1% 97.8%; 34 | --popover: 20 14.3% 4.1%; 35 | --popover-foreground: 60 9.1% 97.8%; 36 | --primary: 20.5 90.2% 48.2%; 37 | --primary-foreground: 60 9.1% 97.8%; 38 | --secondary: 12 6.5% 15.1%; 39 | --secondary-foreground: 60 9.1% 97.8%; 40 | --muted: 12 6.5% 15.1%; 41 | --muted-foreground: 24 5.4% 63.9%; 42 | --accent: 12 6.5% 15.1%; 43 | --accent-foreground: 60 9.1% 97.8%; 44 | --destructive: 0 72.2% 50.6%; 45 | --destructive-foreground: 60 9.1% 97.8%; 46 | --border: 12 6.5% 15.1%; 47 | --input: 12 6.5% 15.1%; 48 | --ring: 20.5 90.2% 48.2%; 49 | } 50 | } 51 | 52 | @layer base { 53 | * { 54 | @apply border-border; 55 | } 56 | body { 57 | @apply bg-background text-foreground; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /app/[lang]/layout.tsx: -------------------------------------------------------------------------------- 1 | import "./globals.css"; 2 | 3 | import { Analytics } from "@vercel/analytics/react"; 4 | import { Inter } from "next/font/google"; 5 | import type { Metadata } from "next"; 6 | import { Toaster } from "sonner"; 7 | import { getDictionary } from "@/services/i18n"; 8 | 9 | const inter = Inter({ subsets: ["latin"] }); 10 | 11 | export async function generateMetadata({ 12 | params, 13 | }: { 14 | params: { lang: string }; 15 | }): Promise { 16 | const dict = await getDictionary(params.lang); 17 | 18 | return { 19 | title: { 20 | template: `%s, ${dict.brand.title} | Sora.FM`, 21 | default: `${dict.brand.title} | Sora.FM`, 22 | }, 23 | description: `${dict.brand.title}, ${dict.brand.sub_title}`, 24 | keywords: 25 | "sora,sora fm,sora ai,openai sora,video ai,ai video,sora video,ai video generator,text to video,sora ai video,sora ai video generator,sora webui,sora showcase,sora ai showcases", 26 | }; 27 | } 28 | 29 | export default function RootLayout({ 30 | children, 31 | params: { lang }, 32 | }: Readonly<{ 33 | children: React.ReactNode; 34 | params: { lang: string }; 35 | }>) { 36 | return ( 37 | 38 | 39 | 40 | 41 | 42 | 43 | {children} 44 | 45 | 46 | 47 | ); 48 | } 49 | -------------------------------------------------------------------------------- /app/api/gen-video/route.ts: -------------------------------------------------------------------------------- 1 | import { respData, respErr } from "@/lib/resp"; 2 | 3 | import { getRandomVideos } from "@/models/video"; 4 | 5 | export async function POST(req: Request) { 6 | try { 7 | const { description } = await req.json(); 8 | if (!description) { 9 | return respErr("invalid params"); 10 | } 11 | 12 | // todo: call openai sora api to generate video 13 | 14 | const videos = await getRandomVideos(1, 1); 15 | if (videos.length === 0) { 16 | return respErr("gen video failed"); 17 | } 18 | 19 | return respData(videos[0]); 20 | } catch (e) { 21 | console.log("gen video failed:", e); 22 | return respErr("gen video failed"); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /app/api/process/update-videos/route.ts: -------------------------------------------------------------------------------- 1 | import { respData, respErr } from "@/lib/resp"; 2 | 3 | import { getVideosFromFile } from "@/services/video"; 4 | import { insertVideo } from "@/models/video"; 5 | 6 | export async function POST(req: Request) { 7 | try { 8 | const allVideos = await getVideosFromFile(); 9 | const allVideosCount = allVideos.length; 10 | 11 | console.log(`all videos count: ${allVideosCount}`); 12 | 13 | let existCount = 0; 14 | let newCount = 0; 15 | let failedCount = 0; 16 | for (let i = 0; i < allVideosCount; i++) { 17 | const video = allVideos[i]; 18 | if (!video.uuid || !video.video_url) { 19 | continue; 20 | } 21 | 22 | video.user_uuid = process.env.ADMIN_USER_UUID; 23 | 24 | if (video.user_nickname === "OpenAI") { 25 | // console.log("video exist: ", video.uuid, video.video_url); 26 | // existCount += 1; 27 | // continue; 28 | } 29 | 30 | try { 31 | // console.log("video", video); 32 | await insertVideo(video); 33 | newCount += 1; 34 | console.log( 35 | "insert new video: ", 36 | video.uuid, 37 | video.video_url, 38 | i, 39 | allVideosCount - i 40 | ); 41 | } catch (e) { 42 | failedCount += 1; 43 | console.log("insert video failed: ", video.uuid, video.video_url, i, e); 44 | } 45 | } 46 | 47 | return respData({ 48 | all_count: allVideosCount, 49 | exist_count: existCount, 50 | new_count: newCount, 51 | failed_count: failedCount, 52 | }); 53 | } catch (e) { 54 | console.log("update videos failed", e); 55 | return respErr("update videos failed"); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /app/api/save-user/route.ts: -------------------------------------------------------------------------------- 1 | import { respData, respErr } from "@/lib/resp"; 2 | 3 | import { User } from "@/types/user"; 4 | import { genUuid } from "@/lib"; 5 | import { saveUser } from "@/services/user"; 6 | 7 | export async function POST(req: Request) { 8 | try { 9 | const { email } = await req.json(); 10 | if (!email) { 11 | return respErr("invalid params"); 12 | } 13 | if (!email.includes("@")) { 14 | return respErr("invalid email"); 15 | } 16 | 17 | const created_at = new Date().toISOString(); 18 | const user_uuid = genUuid(); 19 | 20 | const user: User = { 21 | email: email, 22 | nickname: "", 23 | avatar_url: "", 24 | created_at: created_at, 25 | uuid: user_uuid, 26 | }; 27 | console.log("save user info", user); 28 | 29 | await saveUser(user); 30 | 31 | return respData(user); 32 | } catch (e) { 33 | console.log("save user failed", e); 34 | return respErr("save user failed"); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /components.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://ui.shadcn.com/schema.json", 3 | "style": "default", 4 | "rsc": true, 5 | "tsx": true, 6 | "tailwind": { 7 | "config": "tailwind.config.ts", 8 | "css": "app/globals.css", 9 | "baseColor": "slate", 10 | "cssVariables": true, 11 | "prefix": "" 12 | }, 13 | "aliases": { 14 | "components": "@/components", 15 | "utils": "@/lib/utils" 16 | } 17 | } -------------------------------------------------------------------------------- /components/ui/menubar.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as MenubarPrimitive from "@radix-ui/react-menubar" 5 | import { Check, ChevronRight, Circle } from "lucide-react" 6 | 7 | import { cn } from "@/lib/utils" 8 | 9 | const MenubarMenu = MenubarPrimitive.Menu 10 | 11 | const MenubarGroup = MenubarPrimitive.Group 12 | 13 | const MenubarPortal = MenubarPrimitive.Portal 14 | 15 | const MenubarSub = MenubarPrimitive.Sub 16 | 17 | const MenubarRadioGroup = MenubarPrimitive.RadioGroup 18 | 19 | const Menubar = React.forwardRef< 20 | React.ElementRef, 21 | React.ComponentPropsWithoutRef 22 | >(({ className, ...props }, ref) => ( 23 | 31 | )) 32 | Menubar.displayName = MenubarPrimitive.Root.displayName 33 | 34 | const MenubarTrigger = React.forwardRef< 35 | React.ElementRef, 36 | React.ComponentPropsWithoutRef 37 | >(({ className, ...props }, ref) => ( 38 | 46 | )) 47 | MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName 48 | 49 | const MenubarSubTrigger = React.forwardRef< 50 | React.ElementRef, 51 | React.ComponentPropsWithoutRef & { 52 | inset?: boolean 53 | } 54 | >(({ className, inset, children, ...props }, ref) => ( 55 | 64 | {children} 65 | 66 | 67 | )) 68 | MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName 69 | 70 | const MenubarSubContent = React.forwardRef< 71 | React.ElementRef, 72 | React.ComponentPropsWithoutRef 73 | >(({ className, ...props }, ref) => ( 74 | 82 | )) 83 | MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName 84 | 85 | const MenubarContent = React.forwardRef< 86 | React.ElementRef, 87 | React.ComponentPropsWithoutRef 88 | >( 89 | ( 90 | { className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, 91 | ref 92 | ) => ( 93 | 94 | 105 | 106 | ) 107 | ) 108 | MenubarContent.displayName = MenubarPrimitive.Content.displayName 109 | 110 | const MenubarItem = React.forwardRef< 111 | React.ElementRef, 112 | React.ComponentPropsWithoutRef & { 113 | inset?: boolean 114 | } 115 | >(({ className, inset, ...props }, ref) => ( 116 | 125 | )) 126 | MenubarItem.displayName = MenubarPrimitive.Item.displayName 127 | 128 | const MenubarCheckboxItem = React.forwardRef< 129 | React.ElementRef, 130 | React.ComponentPropsWithoutRef 131 | >(({ className, children, checked, ...props }, ref) => ( 132 | 141 | 142 | 143 | 144 | 145 | 146 | {children} 147 | 148 | )) 149 | MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName 150 | 151 | const MenubarRadioItem = React.forwardRef< 152 | React.ElementRef, 153 | React.ComponentPropsWithoutRef 154 | >(({ className, children, ...props }, ref) => ( 155 | 163 | 164 | 165 | 166 | 167 | 168 | {children} 169 | 170 | )) 171 | MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName 172 | 173 | const MenubarLabel = React.forwardRef< 174 | React.ElementRef, 175 | React.ComponentPropsWithoutRef & { 176 | inset?: boolean 177 | } 178 | >(({ className, inset, ...props }, ref) => ( 179 | 188 | )) 189 | MenubarLabel.displayName = MenubarPrimitive.Label.displayName 190 | 191 | const MenubarSeparator = React.forwardRef< 192 | React.ElementRef, 193 | React.ComponentPropsWithoutRef 194 | >(({ className, ...props }, ref) => ( 195 | 200 | )) 201 | MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName 202 | 203 | const MenubarShortcut = ({ 204 | className, 205 | ...props 206 | }: React.HTMLAttributes) => { 207 | return ( 208 | 215 | ) 216 | } 217 | MenubarShortcut.displayname = "MenubarShortcut" 218 | 219 | export { 220 | Menubar, 221 | MenubarMenu, 222 | MenubarTrigger, 223 | MenubarContent, 224 | MenubarItem, 225 | MenubarSeparator, 226 | MenubarLabel, 227 | MenubarCheckboxItem, 228 | MenubarRadioGroup, 229 | MenubarRadioItem, 230 | MenubarPortal, 231 | MenubarSubContent, 232 | MenubarSubTrigger, 233 | MenubarGroup, 234 | MenubarSub, 235 | MenubarShortcut, 236 | } 237 | -------------------------------------------------------------------------------- /components/ui/select.tsx: -------------------------------------------------------------------------------- 1 | "use client" 2 | 3 | import * as React from "react" 4 | import * as SelectPrimitive from "@radix-ui/react-select" 5 | import { Check, ChevronDown, ChevronUp } from "lucide-react" 6 | 7 | import { cn } from "@/lib/utils" 8 | 9 | const Select = SelectPrimitive.Root 10 | 11 | const SelectGroup = SelectPrimitive.Group 12 | 13 | const SelectValue = SelectPrimitive.Value 14 | 15 | const SelectTrigger = React.forwardRef< 16 | React.ElementRef, 17 | React.ComponentPropsWithoutRef 18 | >(({ className, children, ...props }, ref) => ( 19 | span]:line-clamp-1", 23 | className 24 | )} 25 | {...props} 26 | > 27 | {children} 28 | 29 | 30 | 31 | 32 | )) 33 | SelectTrigger.displayName = SelectPrimitive.Trigger.displayName 34 | 35 | const SelectScrollUpButton = React.forwardRef< 36 | React.ElementRef, 37 | React.ComponentPropsWithoutRef 38 | >(({ className, ...props }, ref) => ( 39 | 47 | 48 | 49 | )) 50 | SelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName 51 | 52 | const SelectScrollDownButton = React.forwardRef< 53 | React.ElementRef, 54 | React.ComponentPropsWithoutRef 55 | >(({ className, ...props }, ref) => ( 56 | 64 | 65 | 66 | )) 67 | SelectScrollDownButton.displayName = 68 | SelectPrimitive.ScrollDownButton.displayName 69 | 70 | const SelectContent = React.forwardRef< 71 | React.ElementRef, 72 | React.ComponentPropsWithoutRef 73 | >(({ className, children, position = "popper", ...props }, ref) => ( 74 | 75 | 86 | 87 | 94 | {children} 95 | 96 | 97 | 98 | 99 | )) 100 | SelectContent.displayName = SelectPrimitive.Content.displayName 101 | 102 | const SelectLabel = React.forwardRef< 103 | React.ElementRef, 104 | React.ComponentPropsWithoutRef 105 | >(({ className, ...props }, ref) => ( 106 | 111 | )) 112 | SelectLabel.displayName = SelectPrimitive.Label.displayName 113 | 114 | const SelectItem = React.forwardRef< 115 | React.ElementRef, 116 | React.ComponentPropsWithoutRef 117 | >(({ className, children, ...props }, ref) => ( 118 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | {children} 133 | 134 | )) 135 | SelectItem.displayName = SelectPrimitive.Item.displayName 136 | 137 | const SelectSeparator = React.forwardRef< 138 | React.ElementRef, 139 | React.ComponentPropsWithoutRef 140 | >(({ className, ...props }, ref) => ( 141 | 146 | )) 147 | SelectSeparator.displayName = SelectPrimitive.Separator.displayName 148 | 149 | export { 150 | Select, 151 | SelectGroup, 152 | SelectValue, 153 | SelectTrigger, 154 | SelectContent, 155 | SelectLabel, 156 | SelectItem, 157 | SelectSeparator, 158 | SelectScrollUpButton, 159 | SelectScrollDownButton, 160 | } 161 | -------------------------------------------------------------------------------- /data/install.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE users ( 2 | id SERIAL PRIMARY KEY, 3 | email VARCHAR(255) UNIQUE NOT NULL, 4 | nickname VARCHAR(50), 5 | avatar_url VARCHAR(255), 6 | created_at timestamptz, 7 | uuid UUID UNIQUE NOT NULL 8 | ); 9 | 10 | CREATE TABLE videos ( 11 | id SERIAL PRIMARY KEY, 12 | user_uuid VARCHAR(255) NOT NULL, 13 | video_description TEXT, 14 | video_url VARCHAR(255), 15 | cover_url VARCHAR(255), 16 | post_url VARCHAR(255), 17 | user_nickname VARCHAR(50), 18 | user_avatar_url VARCHAR(255), 19 | created_at timestamptz, 20 | uuid UUID UNIQUE NOT NULL, 21 | status INT, 22 | is_recommended BOOLEAN 23 | ); -------------------------------------------------------------------------------- /debug/apitest.http: -------------------------------------------------------------------------------- 1 | @baseUri=http://127.0.0.1:8014/api 2 | 3 | ### gen video 4 | POST {{baseUri}}/gen-video 5 | Content-Type: application/json 6 | 7 | { 8 | "description": "spider man fighting with iron man" 9 | } 10 | 11 | ### update videos 12 | POST {{baseUri}}/process/update-videos 13 | Content-Type: application/json -------------------------------------------------------------------------------- /deploy/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:18-alpine AS base 2 | 3 | # Install dependencies only when needed 4 | FROM base AS deps 5 | # Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. 6 | RUN apk add --no-cache libc6-compat && yarn global add pnpm 7 | 8 | WORKDIR /app 9 | 10 | # Install dependencies based on the preferred package manager 11 | COPY package.json pnpm-lock.yaml* ./ 12 | RUN pnpm i --frozen-lockfile 13 | 14 | # Rebuild the source code only when needed 15 | FROM deps AS builder 16 | 17 | WORKDIR /app 18 | 19 | # Install dependencies based on the preferred package manager 20 | COPY . . 21 | RUN pnpm build 22 | 23 | # Production image, copy all the files and run next 24 | FROM base AS runner 25 | WORKDIR /app 26 | 27 | RUN addgroup --system --gid 1001 nodejs && \ 28 | adduser --system --uid 1001 nextjs && \ 29 | mkdir .next && \ 30 | chown nextjs:nodejs .next 31 | 32 | COPY --from=builder /app/public ./public 33 | COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ 34 | COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static 35 | 36 | USER nextjs 37 | 38 | EXPOSE 8080 39 | 40 | ENV NODE_ENV production 41 | 42 | ENV PORT 8080 43 | ENV HOSTNAME "0.0.0.0" 44 | 45 | # server.js is created by next build from the standalone output 46 | # https://nextjs.org/docs/pages/api-reference/next-config-js/output 47 | CMD ["node", "server.js"] -------------------------------------------------------------------------------- /deploy/nginx.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | 4 | location / { 5 | proxy_pass http://127.0.0.1:8014/; 6 | proxy_set_header Host $http_host; 7 | proxy_set_header X-Real-IP $remote_addr; 8 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 9 | proxy_set_header X-Forwarded-Proto $scheme; 10 | } 11 | 12 | error_log /var/log/nginx/sorafm.error; 13 | } -------------------------------------------------------------------------------- /dictionaries/de.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Sora AI Video Generator", 5 | "sub_title": "Erstelle AI Videos mit Sora, entfessele deine Kreativität." 6 | }, 7 | "subscribe": { 8 | "placeholder": "Gib deine E-Mail-Adresse ein", 9 | "button": "Abonnieren", 10 | "tip": "Die Sora Text-zu-Video API ist derzeit nicht verfügbar, wir werden dich informieren, sobald sie live geht." 11 | }, 12 | "showcase": { 13 | "title": "Sora AI Video Showcase", 14 | "sub_title": "Dieses Video wurde mit dem Sora Text-zu-Video Modell erstellt", 15 | "more_tip": "Mehr AI Video Showcases" 16 | }, 17 | "tab": { 18 | "latest": "Neueste", 19 | "featured": "Empfohlen", 20 | "random": "Zufällig" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dictionaries/en.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Sora AI Video Generator", 5 | "sub_title": "Make AI Video with Sora, Unleash your creativity." 6 | }, 7 | "subscribe": { 8 | "placeholder": "Enter your email", 9 | "button": "Subscribe", 10 | "tip": "Sora text-to-video API is not available, we'll get you notified when it's live." 11 | }, 12 | "showcase": { 13 | "title": "Sora AI Video Showcase", 14 | "sub_title": "This video is made with Sora text-to-video model", 15 | "more_tip": "More AI Video Showcases" 16 | }, 17 | "tab": { 18 | "latest": "Latest", 19 | "featured": "Featured", 20 | "random": "Random" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dictionaries/fr.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Générateur de vidéos Sora AI", 5 | "sub_title": "Créez des vidéos AI avec Sora" 6 | }, 7 | "subscribe": { 8 | "placeholder": "Entrez votre email", 9 | "button": "S'abonner", 10 | "tip": "L'API de texte en vidéo Sora n'est pas disponible, nous vous informerons lorsqu'elle sera en ligne." 11 | }, 12 | "showcase": { 13 | "title": "Vitrine vidéo Sora AI", 14 | "sub_title": "Cette vidéo a été réalisée avec Sora, par l'équipe rouge d'OpenAI.", 15 | "more_tip": "Plus de vitrines vidéo AI" 16 | }, 17 | "tab": { 18 | "latest": "Dernier", 19 | "featured": "En vedette", 20 | "random": "Aléatoire" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dictionaries/ja.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Sora AI ビデオジェネレーター", 5 | "sub_title": "Soraを使用してAIビデオを生成する" 6 | }, 7 | "subscribe": { 8 | "placeholder": "メールアドレスを入力してください", 9 | "button": "通知を購読する", 10 | "tip": "SoraテキストからビデオへのAPIは利用できませんが、公開され次第お知らせします。" 11 | }, 12 | "showcase": { 13 | "title": "Sora AI ビデオショーケース", 14 | "sub_title": "このビデオはOpenAIのレッドチームによってSoraを使って作成されました。", 15 | "more_tip": "さらにAIビデオショーケース" 16 | }, 17 | "tab": { 18 | "latest": "最新", 19 | "featured": "注目", 20 | "random": "ランダム" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dictionaries/ko.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Sora AI 비디오 생성기", 5 | "sub_title": "Sora 를 사용하여 AI 비디오를 제작하다" 6 | }, 7 | "subscribe": { 8 | "placeholder": "이메일을 입력하세요", 9 | "button": "알림 구독하기", 10 | "tip": "Sora 텍스트에서 비디오로의 API는 사용할 수 없습니다. 서비스가 시작되면 알려드리겠습니다." 11 | }, 12 | "showcase": { 13 | "title": "Sora AI 비디오 쇼케이스", 14 | "sub_title": "T이 비디오는 OpenAI의 레드 팀이 Sora를 사용하여 만들었습니다.", 15 | "more_tip": "더 많은 AI 비디오 쇼케이스" 16 | }, 17 | "tab": { 18 | "latest": "최신", 19 | "featured": "특집", 20 | "random": "무작위" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /dictionaries/zh.json: -------------------------------------------------------------------------------- 1 | { 2 | "brand": { 3 | "name": "Sora.FM", 4 | "title": "Sora AI 视频生成器", 5 | "sub_title": "使用 Sora 生成 AI 视频,释放你的创造力" 6 | }, 7 | "subscribe": { 8 | "placeholder": "输入你的邮箱", 9 | "button": "订阅通知", 10 | "tip": "Sora 文生视频功能尚未发布,等可用后,我们会第一时间通知你" 11 | }, 12 | "showcase": { 13 | "title": "Sora AI 视频演示", 14 | "sub_title": "这个视频由 Sora 生成", 15 | "more_tip": "更多由 Sora 生成的视频" 16 | }, 17 | "tab": { 18 | "latest": "最新", 19 | "featured": "最热", 20 | "random": "随机" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/index.ts: -------------------------------------------------------------------------------- 1 | import { v4 as uuidv4 } from "uuid"; 2 | 3 | export function genUuid(): string { 4 | return uuidv4(); 5 | } 6 | -------------------------------------------------------------------------------- /lib/resp.ts: -------------------------------------------------------------------------------- 1 | export function respData(data: any) { 2 | return respJson(0, "ok", data || []); 3 | } 4 | 5 | export function respOk() { 6 | return respJson(0, "ok"); 7 | } 8 | 9 | export function respErr(message: string) { 10 | return respJson(-1, message); 11 | } 12 | 13 | export function respJson(code: number, message: string, data?: any) { 14 | let json = { 15 | code: code, 16 | message: message, 17 | data: data, 18 | }; 19 | if (data) { 20 | json["data"] = data; 21 | } 22 | 23 | return Response.json(json); 24 | } 25 | -------------------------------------------------------------------------------- /lib/utils.ts: -------------------------------------------------------------------------------- 1 | import { type ClassValue, clsx } from "clsx" 2 | import { twMerge } from "tailwind-merge" 3 | 4 | export function cn(...inputs: ClassValue[]) { 5 | return twMerge(clsx(inputs)) 6 | } 7 | -------------------------------------------------------------------------------- /middleware.ts: -------------------------------------------------------------------------------- 1 | import { defaultLocale, getLocale, locales } from "./services/i18n"; 2 | 3 | import { NextRequest } from "next/server"; 4 | 5 | export function middleware(request: NextRequest) { 6 | const { pathname } = request.nextUrl; 7 | if (pathname === "/favicon.ico" || pathname.startsWith("/api/")) { 8 | return; 9 | } 10 | 11 | const pathnameHasLocale = locales.some( 12 | (locale) => pathname.startsWith(`/${locale}/`) || pathname === `/${locale}` 13 | ); 14 | 15 | if (pathnameHasLocale) return; 16 | 17 | const locale = getLocale({ 18 | "accept-language": request.headers.get("accept-language"), 19 | }); 20 | 21 | request.nextUrl.pathname = `/${locale}${pathname}`; 22 | 23 | return Response.redirect(request.nextUrl); 24 | } 25 | 26 | export const config = { 27 | matcher: ["/((?!_next).*)"], 28 | }; 29 | -------------------------------------------------------------------------------- /models/db.ts: -------------------------------------------------------------------------------- 1 | import { Pool } from "pg"; 2 | 3 | let globalPool: Pool; 4 | 5 | export function getDb() { 6 | if (!globalPool) { 7 | const connectionString = process.env.POSTGRES_URL; 8 | console.log("connectionString", connectionString); 9 | 10 | globalPool = new Pool({ 11 | connectionString, 12 | }); 13 | } 14 | 15 | return globalPool; 16 | } 17 | -------------------------------------------------------------------------------- /models/user.ts: -------------------------------------------------------------------------------- 1 | import { User } from "@/types/user"; 2 | import { getDb } from "@/models/db"; 3 | 4 | export async function insertUser(user: User) { 5 | const createdAt: string = new Date().toISOString(); 6 | 7 | const db = await getDb(); 8 | const res = await db.query( 9 | `INSERT INTO users 10 | (email, nickname, avatar_url, created_at, uuid) 11 | VALUES 12 | ($1, $2, $3, $4, $5) 13 | `, 14 | [user.email, user.nickname, user.avatar_url, createdAt, user.uuid] 15 | ); 16 | 17 | return res; 18 | } 19 | 20 | export async function findUserByEmail( 21 | email: string 22 | ): Promise { 23 | const db = getDb(); 24 | const res = await db.query(`SELECT * FROM users WHERE email = $1 LIMIT 1`, [ 25 | email, 26 | ]); 27 | if (res.rowCount === 0) { 28 | return undefined; 29 | } 30 | 31 | const { rows } = res; 32 | const row = rows[0]; 33 | const user: User = { 34 | email: row.email, 35 | nickname: row.nickname, 36 | avatar_url: row.avatar_url, 37 | created_at: row.created_at, 38 | uuid: row.uuid, 39 | }; 40 | 41 | return user; 42 | } 43 | 44 | export async function findUserByUuid(uuid: string): Promise { 45 | const db = getDb(); 46 | const res = await db.query(`SELECT * FROM users WHERE uuid = $1 LIMIT 1`, [ 47 | uuid, 48 | ]); 49 | if (res.rowCount === 0) { 50 | return undefined; 51 | } 52 | 53 | const { rows } = res; 54 | const row = rows[0]; 55 | const user: User = { 56 | email: row.email, 57 | nickname: row.nickname, 58 | avatar_url: row.avatar_url, 59 | created_at: row.created_at, 60 | uuid: row.uuid, 61 | }; 62 | 63 | return user; 64 | } 65 | -------------------------------------------------------------------------------- /models/video.ts: -------------------------------------------------------------------------------- 1 | import { QueryResult, QueryResultRow } from "pg"; 2 | 3 | import { Video } from "@/types/video"; 4 | import { getDb } from "./db"; 5 | 6 | export async function insertVideo(video: Video) { 7 | const db = getDb(); 8 | const res = await db.query( 9 | `INSERT INTO videos 10 | (user_uuid, video_description, video_url, cover_url, post_url, user_nickname, user_avatar_url, created_at, uuid, status) 11 | VALUES 12 | ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) 13 | `, 14 | [ 15 | video.user_uuid, 16 | video.video_description, 17 | video.video_url, 18 | video.cover_url, 19 | video.post_url, 20 | video.user_nickname, 21 | video.user_avatar_url, 22 | video.created_at, 23 | video.uuid, 24 | video.status, 25 | ] 26 | ); 27 | 28 | return res; 29 | } 30 | 31 | export async function getVideosCount(): Promise { 32 | const db = getDb(); 33 | const res = await db.query(`SELECT count(1) as count FROM videos`); 34 | if (res.rowCount === 0) { 35 | return 0; 36 | } 37 | 38 | const { rows } = res; 39 | const row = rows[0]; 40 | 41 | return row.count; 42 | } 43 | 44 | export async function getUserVideosCount(user_uuid: string): Promise { 45 | const db = getDb(); 46 | const res = await db.query( 47 | `SELECT count(1) as count FROM videos WHERE user_uuid = $1`, 48 | [user_uuid] 49 | ); 50 | if (res.rowCount === 0) { 51 | return 0; 52 | } 53 | 54 | const { rows } = res; 55 | const row = rows[0]; 56 | 57 | return row.count; 58 | } 59 | 60 | export async function findVideoByUuid( 61 | uuid: string 62 | ): Promise