jbilcke-hf HF Staff commited on
Commit
83f2577
·
1 Parent(s): f26b729

working on shareability/virality

Browse files
PROMPT_CONTEXT.md CHANGED
@@ -4,7 +4,7 @@ our app is an AI video generation platform, where people use the frontend app (w
4
 
5
  Note that this uses a custom API written in Python, with a WebSockets communication.
6
 
7
- To go back to the Flutter app, when the user open a thumbnail card after doing such generative AI search, it opens a full view for a video (with a player, title, description, chat section etc).
8
 
9
 
10
  Task to perform: <fill your demand here>
 
4
 
5
  Note that this uses a custom API written in Python, with a WebSockets communication.
6
 
7
+ To go back to the Flutter app, when the user open a thumbnail card after doing such generative AI search, it opens a full view for a video (with a player, title, description, chat section etc and a special search bar in the top header that allows to edit the current video's theme).
8
 
9
 
10
  Task to perform: <fill your demand here>
api_config.py CHANGED
@@ -60,7 +60,7 @@ CONFIG_FOR_ANONYMOUS_USERS = {
60
  "max_concurrent_generations": 2,
61
 
62
  "min_num_inference_steps": 2,
63
- "default_num_inference_steps": 2,
64
  "max_num_inference_steps": 4,
65
 
66
  "min_num_frames": 9, # 8 + 1
@@ -71,9 +71,9 @@ CONFIG_FOR_ANONYMOUS_USERS = {
71
  "default_clip_duration_seconds": 2,
72
  "max_clip_duration_seconds": 2,
73
 
74
- "min_clip_playback_speed": 0.5,
75
- "default_clip_playback_speed": 0.5,
76
- "max_clip_playback_speed": 0.5,
77
 
78
  "min_clip_framerate": 8,
79
  "default_clip_framerate": 16,
@@ -107,9 +107,9 @@ CONFIG_FOR_STANDARD_HF_USERS = {
107
  "default_clip_duration_seconds": 2,
108
  "max_clip_duration_seconds": 2,
109
 
110
- "min_clip_playback_speed": 0.5,
111
- "default_clip_playback_speed": 0.7,
112
- "max_clip_playback_speed": 0.7,
113
 
114
  "min_clip_framerate": 8,
115
  "default_clip_framerate": 25,
@@ -142,7 +142,7 @@ CONFIG_FOR_PRO_HF_USERS = {
142
  "default_clip_duration_seconds": 2,
143
  "max_clip_duration_seconds": 3,
144
 
145
- "min_clip_playback_speed": 0.5,
146
  "default_clip_playback_speed": 0.8,
147
  "max_clip_playback_speed": 0.8,
148
 
@@ -177,7 +177,7 @@ CONFIG_FOR_ADMIN_HF_USERS = {
177
  "default_clip_duration_seconds": 2,
178
  "max_clip_duration_seconds": 4,
179
 
180
- "min_clip_playback_speed": 0.5,
181
  "default_clip_playback_speed": 0.8,
182
  "max_clip_playback_speed": 0.9,
183
 
@@ -193,3 +193,5 @@ CONFIG_FOR_ADMIN_HF_USERS = {
193
  "default_clip_height": 480,
194
  "max_clip_height": 704,
195
  }
 
 
 
60
  "max_concurrent_generations": 2,
61
 
62
  "min_num_inference_steps": 2,
63
+ "default_num_inference_steps": 3,
64
  "max_num_inference_steps": 4,
65
 
66
  "min_num_frames": 9, # 8 + 1
 
71
  "default_clip_duration_seconds": 2,
72
  "max_clip_duration_seconds": 2,
73
 
74
+ "min_clip_playback_speed": 0.7,
75
+ "default_clip_playback_speed": 0.7,
76
+ "max_clip_playback_speed": 0.7,
77
 
78
  "min_clip_framerate": 8,
79
  "default_clip_framerate": 16,
 
107
  "default_clip_duration_seconds": 2,
108
  "max_clip_duration_seconds": 2,
109
 
110
+ "min_clip_playback_speed": 0.7,
111
+ "default_clip_playback_speed": 0.8,
112
+ "max_clip_playback_speed": 0.8,
113
 
114
  "min_clip_framerate": 8,
115
  "default_clip_framerate": 25,
 
142
  "default_clip_duration_seconds": 2,
143
  "max_clip_duration_seconds": 3,
144
 
145
+ "min_clip_playback_speed": 0.7,
146
  "default_clip_playback_speed": 0.8,
147
  "max_clip_playback_speed": 0.8,
148
 
 
177
  "default_clip_duration_seconds": 2,
178
  "max_clip_duration_seconds": 4,
179
 
180
+ "min_clip_playback_speed": 0.7,
181
  "default_clip_playback_speed": 0.8,
182
  "max_clip_playback_speed": 0.9,
183
 
 
193
  "default_clip_height": 480,
194
  "max_clip_height": 704,
195
  }
196
+
197
+ CONFIG_FOR_ANONYMOUS_USERS = CONFIG_FOR_STANDARD_HF_USERS
api_core.py CHANGED
@@ -298,16 +298,15 @@ class VideoGenerationAPI:
298
  """Generate a single search result using HF text generation"""
299
  prompt = f"""# Instruction
300
  Your response MUST be a YAML object containing a title, description, and tags, consistent with what we can find on a video sharing platform.
301
- Format your YAML response with only those fields: "title" (single string of a short sentence), "description" (single string of a few sentences to describe the visuals: characters, age, gender, action, location, lighting, country, costume, time, weather, textures, color palette), and "tags" (array of strings). Do not add any other field.
302
- The description is a prompt for a generative AI, so please describe the visual elements of the scene in details, including: camera angle and focus, people's appearance, their age, actions, precise look, clothing, the location characteristics, lighting, action, objects, weather, texture, color palette. Write as if you were describing the scene to a photograph.
303
  Make the result unique and different from previous search results. ONLY RETURN YAML AND WITH ENGLISH CONTENT, NOT CHINESE - DO NOT ADD ANY OTHER COMMENT!
304
 
305
  # Context
306
  This is attempt {attempt_count} at generating search result number {search_count}.
307
 
308
  # Input
309
- Describe the appearance of a video scene for this theme: "{query}".
310
- Don't use bullet points or titles/prefixes in your description. Just describe it in plain natural language.
311
 
312
  # Output
313
 
 
298
  """Generate a single search result using HF text generation"""
299
  prompt = f"""# Instruction
300
  Your response MUST be a YAML object containing a title, description, and tags, consistent with what we can find on a video sharing platform.
301
+ Format your YAML response with only those fields: "title" (a short string), "description" (string caption of the scene), and "tags" (array of 3 to 4 strings). Do not add any other field.
302
+ In the description field, describe in a very synthetic way the visuals of the first shot (first scene), eg "<STYLE>, medium close-up shot, high angle view of a <AGE>yo <GENDER> <CHARACTERS> <ACTIONS>, <LOCATION> <LIGHTING> <WEATHER>". Keep it minimalist but still descriptive, don't use bullets points, use simple words, go to the essential to describe style (cinematic, documentary footage, 3D rendering..), camera modes and angles, characters, age, gender, action, location, lighting, country, costume, time, weather, textures, color palette.. etc.
303
  Make the result unique and different from previous search results. ONLY RETURN YAML AND WITH ENGLISH CONTENT, NOT CHINESE - DO NOT ADD ANY OTHER COMMENT!
304
 
305
  # Context
306
  This is attempt {attempt_count} at generating search result number {search_count}.
307
 
308
  # Input
309
+ Describe the first scene/shot for: "{query}".
 
310
 
311
  # Output
312
 
build/web/assets/NOTICES CHANGED
@@ -2034,6 +2034,36 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2034
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2035
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2036
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2037
  --------------------------------------------------------------------------------
2038
  clock
2039
  fake_async
@@ -32574,6 +32604,459 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32574
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32575
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32576
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32577
  --------------------------------------------------------------------------------
32578
  uuid
32579
 
 
2034
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2035
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2036
 
2037
+ --------------------------------------------------------------------------------
2038
+ charcode
2039
+
2040
+ Copyright 2014, the Dart project authors. All rights reserved.
2041
+ Redistribution and use in source and binary forms, with or without
2042
+ modification, are permitted provided that the following conditions are
2043
+ met:
2044
+
2045
+ * Redistributions of source code must retain the above copyright
2046
+ notice, this list of conditions and the following disclaimer.
2047
+ * Redistributions in binary form must reproduce the above
2048
+ copyright notice, this list of conditions and the following
2049
+ disclaimer in the documentation and/or other materials provided
2050
+ with the distribution.
2051
+ * Neither the name of Google Inc. nor the names of its
2052
+ contributors may be used to endorse or promote products derived
2053
+ from this software without specific prior written permission.
2054
+
2055
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
2056
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
2057
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
2058
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
2059
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
2060
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
2061
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
2062
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
2063
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2064
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
2065
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2066
+
2067
  --------------------------------------------------------------------------------
2068
  clock
2069
  fake_async
 
32604
  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32605
  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32606
 
32607
+ --------------------------------------------------------------------------------
32608
+ universal_html
32609
+
32610
+ Apache License
32611
+ Version 2.0, January 2004
32612
+ http://www.apache.org/licenses/
32613
+
32614
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
32615
+
32616
+ 1. Definitions.
32617
+
32618
+ "License" shall mean the terms and conditions for use, reproduction,
32619
+ and distribution as defined by Sections 1 through 9 of this document.
32620
+
32621
+ "Licensor" shall mean the copyright owner or entity authorized by
32622
+ the copyright owner that is granting the License.
32623
+
32624
+ "Legal Entity" shall mean the union of the acting entity and all
32625
+ other entities that control, are controlled by, or are under common
32626
+ control with that entity. For the purposes of this definition,
32627
+ "control" means (i) the power, direct or indirect, to cause the
32628
+ direction or management of such entity, whether by contract or
32629
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
32630
+ outstanding shares, or (iii) beneficial ownership of such entity.
32631
+
32632
+ "You" (or "Your") shall mean an individual or Legal Entity
32633
+ exercising permissions granted by this License.
32634
+
32635
+ "Source" form shall mean the preferred form for making modifications,
32636
+ including but not limited to software source code, documentation
32637
+ source, and configuration files.
32638
+
32639
+ "Object" form shall mean any form resulting from mechanical
32640
+ transformation or translation of a Source form, including but
32641
+ not limited to compiled object code, generated documentation,
32642
+ and conversions to other media types.
32643
+
32644
+ "Work" shall mean the work of authorship, whether in Source or
32645
+ Object form, made available under the License, as indicated by a
32646
+ copyright notice that is included in or attached to the work
32647
+ (an example is provided in the Appendix below).
32648
+
32649
+ "Derivative Works" shall mean any work, whether in Source or Object
32650
+ form, that is based on (or derived from) the Work and for which the
32651
+ editorial revisions, annotations, elaborations, or other modifications
32652
+ represent, as a whole, an original work of authorship. For the purposes
32653
+ of this License, Derivative Works shall not include works that remain
32654
+ separable from, or merely link (or bind by name) to the interfaces of,
32655
+ the Work and Derivative Works thereof.
32656
+
32657
+ "Contribution" shall mean any work of authorship, including
32658
+ the original version of the Work and any modifications or additions
32659
+ to that Work or Derivative Works thereof, that is intentionally
32660
+ submitted to Licensor for inclusion in the Work by the copyright owner
32661
+ or by an individual or Legal Entity authorized to submit on behalf of
32662
+ the copyright owner. For the purposes of this definition, "submitted"
32663
+ means any form of electronic, verbal, or written communication sent
32664
+ to the Licensor or its representatives, including but not limited to
32665
+ communication on electronic mailing lists, source code control systems,
32666
+ and issue tracking systems that are managed by, or on behalf of, the
32667
+ Licensor for the purpose of discussing and improving the Work, but
32668
+ excluding communication that is conspicuously marked or otherwise
32669
+ designated in writing by the copyright owner as "Not a Contribution."
32670
+
32671
+ "Contributor" shall mean Licensor and any individual or Legal Entity
32672
+ on behalf of whom a Contribution has been received by Licensor and
32673
+ subsequently incorporated within the Work.
32674
+
32675
+ 2. Grant of Copyright License. Subject to the terms and conditions of
32676
+ this License, each Contributor hereby grants to You a perpetual,
32677
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
32678
+ copyright license to reproduce, prepare Derivative Works of,
32679
+ publicly display, publicly perform, sublicense, and distribute the
32680
+ Work and such Derivative Works in Source or Object form.
32681
+
32682
+ 3. Grant of Patent License. Subject to the terms and conditions of
32683
+ this License, each Contributor hereby grants to You a perpetual,
32684
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
32685
+ (except as stated in this section) patent license to make, have made,
32686
+ use, offer to sell, sell, import, and otherwise transfer the Work,
32687
+ where such license applies only to those patent claims licensable
32688
+ by such Contributor that are necessarily infringed by their
32689
+ Contribution(s) alone or by combination of their Contribution(s)
32690
+ with the Work to which such Contribution(s) was submitted. If You
32691
+ institute patent litigation against any entity (including a
32692
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
32693
+ or a Contribution incorporated within the Work constitutes direct
32694
+ or contributory patent infringement, then any patent licenses
32695
+ granted to You under this License for that Work shall terminate
32696
+ as of the date such litigation is filed.
32697
+
32698
+ 4. Redistribution. You may reproduce and distribute copies of the
32699
+ Work or Derivative Works thereof in any medium, with or without
32700
+ modifications, and in Source or Object form, provided that You
32701
+ meet the following conditions:
32702
+
32703
+ (a) You must give any other recipients of the Work or
32704
+ Derivative Works a copy of this License; and
32705
+
32706
+ (b) You must cause any modified files to carry prominent notices
32707
+ stating that You changed the files; and
32708
+
32709
+ (c) You must retain, in the Source form of any Derivative Works
32710
+ that You distribute, all copyright, patent, trademark, and
32711
+ attribution notices from the Source form of the Work,
32712
+ excluding those notices that do not pertain to any part of
32713
+ the Derivative Works; and
32714
+
32715
+ (d) If the Work includes a "NOTICE" text file as part of its
32716
+ distribution, then any Derivative Works that You distribute must
32717
+ include a readable copy of the attribution notices contained
32718
+ within such NOTICE file, excluding those notices that do not
32719
+ pertain to any part of the Derivative Works, in at least one
32720
+ of the following places: within a NOTICE text file distributed
32721
+ as part of the Derivative Works; within the Source form or
32722
+ documentation, if provided along with the Derivative Works; or,
32723
+ within a display generated by the Derivative Works, if and
32724
+ wherever such third-party notices normally appear. The contents
32725
+ of the NOTICE file are for informational purposes only and
32726
+ do not modify the License. You may add Your own attribution
32727
+ notices within Derivative Works that You distribute, alongside
32728
+ or as an addendum to the NOTICE text from the Work, provided
32729
+ that such additional attribution notices cannot be construed
32730
+ as modifying the License.
32731
+
32732
+ You may add Your own copyright statement to Your modifications and
32733
+ may provide additional or different license terms and conditions
32734
+ for use, reproduction, or distribution of Your modifications, or
32735
+ for any such Derivative Works as a whole, provided Your use,
32736
+ reproduction, and distribution of the Work otherwise complies with
32737
+ the conditions stated in this License.
32738
+
32739
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
32740
+ any Contribution intentionally submitted for inclusion in the Work
32741
+ by You to the Licensor shall be under the terms and conditions of
32742
+ this License, without any additional terms or conditions.
32743
+ Notwithstanding the above, nothing herein shall supersede or modify
32744
+ the terms of any separate license agreement you may have executed
32745
+ with Licensor regarding such Contributions.
32746
+
32747
+ 6. Trademarks. This License does not grant permission to use the trade
32748
+ names, trademarks, service marks, or product names of the Licensor,
32749
+ except as required for reasonable and customary use in describing the
32750
+ origin of the Work and reproducing the content of the NOTICE file.
32751
+
32752
+ 7. Disclaimer of Warranty. Unless required by applicable law or
32753
+ agreed to in writing, Licensor provides the Work (and each
32754
+ Contributor provides its Contributions) on an "AS IS" BASIS,
32755
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
32756
+ implied, including, without limitation, any warranties or conditions
32757
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
32758
+ PARTICULAR PURPOSE. You are solely responsible for determining the
32759
+ appropriateness of using or redistributing the Work and assume any
32760
+ risks associated with Your exercise of permissions under this License.
32761
+
32762
+ 8. Limitation of Liability. In no event and under no legal theory,
32763
+ whether in tort (including negligence), contract, or otherwise,
32764
+ unless required by applicable law (such as deliberate and grossly
32765
+ negligent acts) or agreed to in writing, shall any Contributor be
32766
+ liable to You for damages, including any direct, indirect, special,
32767
+ incidental, or consequential damages of any character arising as a
32768
+ result of this License or out of the use or inability to use the
32769
+ Work (including but not limited to damages for loss of goodwill,
32770
+ work stoppage, computer failure or malfunction, or any and all
32771
+ other commercial damages or losses), even if such Contributor
32772
+ has been advised of the possibility of such damages.
32773
+
32774
+ 9. Accepting Warranty or Additional Liability. While redistributing
32775
+ the Work or Derivative Works thereof, You may choose to offer,
32776
+ and charge a fee for, acceptance of support, warranty, indemnity,
32777
+ or other liability obligations and/or rights consistent with this
32778
+ License. However, in accepting such obligations, You may act only
32779
+ on Your own behalf and on Your sole responsibility, not on behalf
32780
+ of any other Contributor, and only if You agree to indemnify,
32781
+ defend, and hold each Contributor harmless for any liability
32782
+ incurred by, or claims asserted against, such Contributor by reason
32783
+ of your accepting any such warranty or additional liability.
32784
+
32785
+ END OF TERMS AND CONDITIONS
32786
+
32787
+ APPENDIX: How to apply the Apache License to your work.
32788
+
32789
+ To apply the Apache License to your work, attach the following
32790
+ boilerplate notice, with the fields enclosed by brackets "[]"
32791
+ replaced with your own identifying information. (Don't include
32792
+ the brackets!) The text should be enclosed in the appropriate
32793
+ comment syntax for the file format. We also recommend that a
32794
+ file or class name and description of purpose be included on the
32795
+ same "printed page" as the copyright notice for easier
32796
+ identification within third-party archives.
32797
+
32798
+ Copyright [yyyy] [name of copyright owner]
32799
+
32800
+ Licensed under the Apache License, Version 2.0 (the "License");
32801
+ you may not use this file except in compliance with the License.
32802
+ You may obtain a copy of the License at
32803
+
32804
+ http://www.apache.org/licenses/LICENSE-2.0
32805
+
32806
+ Unless required by applicable law or agreed to in writing, software
32807
+ distributed under the License is distributed on an "AS IS" BASIS,
32808
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
32809
+ See the License for the specific language governing permissions and
32810
+ limitations under the License.
32811
+
32812
+ ----------------------------------------------------------------------------------------------------
32813
+
32814
+ This version of "universal_html" contains source code from the Dart package "csslib", which was
32815
+ obtained from:
32816
+ https://github.com/dart-lang/csslib
32817
+
32818
+ When the source code was obtained, the original source code had the following license:
32819
+
32820
+ Copyright 2013, the Dart project authors. All rights reserved.
32821
+ Redistribution and use in source and binary forms, with or without
32822
+ modification, are permitted provided that the following conditions are
32823
+ met:
32824
+
32825
+ * Redistributions of source code must retain the above copyright
32826
+ notice, this list of conditions and the following disclaimer.
32827
+ * Redistributions in binary form must reproduce the above
32828
+ copyright notice, this list of conditions and the following
32829
+ disclaimer in the documentation and/or other materials provided
32830
+ with the distribution.
32831
+ * Neither the name of Google Inc. nor the names of its
32832
+ contributors may be used to endorse or promote products derived
32833
+ from this software without specific prior written permission.
32834
+
32835
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32836
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
32837
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
32838
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
32839
+ OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
32840
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32841
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32842
+ DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32843
+ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32844
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32845
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32846
+
32847
+ ----------------------------------------------------------------------------------------------------
32848
+
32849
+ This version of "universal_html" contains source code from the Dart package "html", which was
32850
+ obtained copied from:
32851
+ https://github.com/dart-lang/html
32852
+
32853
+ When the source code was obtained, the original source code had the following license:
32854
+
32855
+ Copyright (c) 2006-2012 The Authors
32856
+
32857
+ Contributors:
32858
+ James Graham - [email protected]
32859
+ Anne van Kesteren - [email protected]
32860
+ Lachlan Hunt - [email protected]
32861
+ Matt McDonald - [email protected]
32862
+ Sam Ruby - [email protected]
32863
+ Ian Hickson (Google) - [email protected]
32864
+ Thomas Broyer - [email protected]
32865
+ Jacques Distler - [email protected]
32866
+ Henri Sivonen - [email protected]
32867
+ Adam Barth - [email protected]
32868
+ Eric Seidel - [email protected]
32869
+ The Mozilla Foundation (contributions from Henri Sivonen since 2008)
32870
+ David Flanagan (Mozilla) - [email protected]
32871
+ Google Inc. (contributed the Dart port) - [email protected]
32872
+
32873
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
32874
+
32875
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32876
+
32877
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32878
+
32879
+ ----------------------------------------------------------------------------------------------------
32880
+
32881
+ --------------------------------------------------------------------------------
32882
+ universal_io
32883
+
32884
+ Apache License
32885
+ Version 2.0, January 2004
32886
+ http://www.apache.org/licenses/
32887
+
32888
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
32889
+
32890
+ 1. Definitions.
32891
+
32892
+ "License" shall mean the terms and conditions for use, reproduction,
32893
+ and distribution as defined by Sections 1 through 9 of this document.
32894
+
32895
+ "Licensor" shall mean the copyright owner or entity authorized by
32896
+ the copyright owner that is granting the License.
32897
+
32898
+ "Legal Entity" shall mean the union of the acting entity and all
32899
+ other entities that control, are controlled by, or are under common
32900
+ control with that entity. For the purposes of this definition,
32901
+ "control" means (i) the power, direct or indirect, to cause the
32902
+ direction or management of such entity, whether by contract or
32903
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
32904
+ outstanding shares, or (iii) beneficial ownership of such entity.
32905
+
32906
+ "You" (or "Your") shall mean an individual or Legal Entity
32907
+ exercising permissions granted by this License.
32908
+
32909
+ "Source" form shall mean the preferred form for making modifications,
32910
+ including but not limited to software source code, documentation
32911
+ source, and configuration files.
32912
+
32913
+ "Object" form shall mean any form resulting from mechanical
32914
+ transformation or translation of a Source form, including but
32915
+ not limited to compiled object code, generated documentation,
32916
+ and conversions to other media types.
32917
+
32918
+ "Work" shall mean the work of authorship, whether in Source or
32919
+ Object form, made available under the License, as indicated by a
32920
+ copyright notice that is included in or attached to the work
32921
+ (an example is provided in the Appendix below).
32922
+
32923
+ "Derivative Works" shall mean any work, whether in Source or Object
32924
+ form, that is based on (or derived from) the Work and for which the
32925
+ editorial revisions, annotations, elaborations, or other modifications
32926
+ represent, as a whole, an original work of authorship. For the purposes
32927
+ of this License, Derivative Works shall not include works that remain
32928
+ separable from, or merely link (or bind by name) to the interfaces of,
32929
+ the Work and Derivative Works thereof.
32930
+
32931
+ "Contribution" shall mean any work of authorship, including
32932
+ the original version of the Work and any modifications or additions
32933
+ to that Work or Derivative Works thereof, that is intentionally
32934
+ submitted to Licensor for inclusion in the Work by the copyright owner
32935
+ or by an individual or Legal Entity authorized to submit on behalf of
32936
+ the copyright owner. For the purposes of this definition, "submitted"
32937
+ means any form of electronic, verbal, or written communication sent
32938
+ to the Licensor or its representatives, including but not limited to
32939
+ communication on electronic mailing lists, source code control systems,
32940
+ and issue tracking systems that are managed by, or on behalf of, the
32941
+ Licensor for the purpose of discussing and improving the Work, but
32942
+ excluding communication that is conspicuously marked or otherwise
32943
+ designated in writing by the copyright owner as "Not a Contribution."
32944
+
32945
+ "Contributor" shall mean Licensor and any individual or Legal Entity
32946
+ on behalf of whom a Contribution has been received by Licensor and
32947
+ subsequently incorporated within the Work.
32948
+
32949
+ 2. Grant of Copyright License. Subject to the terms and conditions of
32950
+ this License, each Contributor hereby grants to You a perpetual,
32951
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
32952
+ copyright license to reproduce, prepare Derivative Works of,
32953
+ publicly display, publicly perform, sublicense, and distribute the
32954
+ Work and such Derivative Works in Source or Object form.
32955
+
32956
+ 3. Grant of Patent License. Subject to the terms and conditions of
32957
+ this License, each Contributor hereby grants to You a perpetual,
32958
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
32959
+ (except as stated in this section) patent license to make, have made,
32960
+ use, offer to sell, sell, import, and otherwise transfer the Work,
32961
+ where such license applies only to those patent claims licensable
32962
+ by such Contributor that are necessarily infringed by their
32963
+ Contribution(s) alone or by combination of their Contribution(s)
32964
+ with the Work to which such Contribution(s) was submitted. If You
32965
+ institute patent litigation against any entity (including a
32966
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
32967
+ or a Contribution incorporated within the Work constitutes direct
32968
+ or contributory patent infringement, then any patent licenses
32969
+ granted to You under this License for that Work shall terminate
32970
+ as of the date such litigation is filed.
32971
+
32972
+ 4. Redistribution. You may reproduce and distribute copies of the
32973
+ Work or Derivative Works thereof in any medium, with or without
32974
+ modifications, and in Source or Object form, provided that You
32975
+ meet the following conditions:
32976
+
32977
+ (a) You must give any other recipients of the Work or
32978
+ Derivative Works a copy of this License; and
32979
+
32980
+ (b) You must cause any modified files to carry prominent notices
32981
+ stating that You changed the files; and
32982
+
32983
+ (c) You must retain, in the Source form of any Derivative Works
32984
+ that You distribute, all copyright, patent, trademark, and
32985
+ attribution notices from the Source form of the Work,
32986
+ excluding those notices that do not pertain to any part of
32987
+ the Derivative Works; and
32988
+
32989
+ (d) If the Work includes a "NOTICE" text file as part of its
32990
+ distribution, then any Derivative Works that You distribute must
32991
+ include a readable copy of the attribution notices contained
32992
+ within such NOTICE file, excluding those notices that do not
32993
+ pertain to any part of the Derivative Works, in at least one
32994
+ of the following places: within a NOTICE text file distributed
32995
+ as part of the Derivative Works; within the Source form or
32996
+ documentation, if provided along with the Derivative Works; or,
32997
+ within a display generated by the Derivative Works, if and
32998
+ wherever such third-party notices normally appear. The contents
32999
+ of the NOTICE file are for informational purposes only and
33000
+ do not modify the License. You may add Your own attribution
33001
+ notices within Derivative Works that You distribute, alongside
33002
+ or as an addendum to the NOTICE text from the Work, provided
33003
+ that such additional attribution notices cannot be construed
33004
+ as modifying the License.
33005
+
33006
+ You may add Your own copyright statement to Your modifications and
33007
+ may provide additional or different license terms and conditions
33008
+ for use, reproduction, or distribution of Your modifications, or
33009
+ for any such Derivative Works as a whole, provided Your use,
33010
+ reproduction, and distribution of the Work otherwise complies with
33011
+ the conditions stated in this License.
33012
+
33013
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
33014
+ any Contribution intentionally submitted for inclusion in the Work
33015
+ by You to the Licensor shall be under the terms and conditions of
33016
+ this License, without any additional terms or conditions.
33017
+ Notwithstanding the above, nothing herein shall supersede or modify
33018
+ the terms of any separate license agreement you may have executed
33019
+ with Licensor regarding such Contributions.
33020
+
33021
+ 6. Trademarks. This License does not grant permission to use the trade
33022
+ names, trademarks, service marks, or product names of the Licensor,
33023
+ except as required for reasonable and customary use in describing the
33024
+ origin of the Work and reproducing the content of the NOTICE file.
33025
+
33026
+ 7. Disclaimer of Warranty. Unless required by applicable law or
33027
+ agreed to in writing, Licensor provides the Work (and each
33028
+ Contributor provides its Contributions) on an "AS IS" BASIS,
33029
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
33030
+ implied, including, without limitation, any warranties or conditions
33031
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
33032
+ PARTICULAR PURPOSE. You are solely responsible for determining the
33033
+ appropriateness of using or redistributing the Work and assume any
33034
+ risks associated with Your exercise of permissions under this License.
33035
+
33036
+ 8. Limitation of Liability. In no event and under no legal theory,
33037
+ whether in tort (including negligence), contract, or otherwise,
33038
+ unless required by applicable law (such as deliberate and grossly
33039
+ negligent acts) or agreed to in writing, shall any Contributor be
33040
+ liable to You for damages, including any direct, indirect, special,
33041
+ incidental, or consequential damages of any character arising as a
33042
+ result of this License or out of the use or inability to use the
33043
+ Work (including but not limited to damages for loss of goodwill,
33044
+ work stoppage, computer failure or malfunction, or any and all
33045
+ other commercial damages or losses), even if such Contributor
33046
+ has been advised of the possibility of such damages.
33047
+
33048
+ 9. Accepting Warranty or Additional Liability. While redistributing
33049
+ the Work or Derivative Works thereof, You may choose to offer,
33050
+ and charge a fee for, acceptance of support, warranty, indemnity,
33051
+ or other liability obligations and/or rights consistent with this
33052
+ License. However, in accepting such obligations, You may act only
33053
+ on Your own behalf and on Your sole responsibility, not on behalf
33054
+ of any other Contributor, and only if You agree to indemnify,
33055
+ defend, and hold each Contributor harmless for any liability
33056
+ incurred by, or claims asserted against, such Contributor by reason
33057
+ of your accepting any such warranty or additional liability.
33058
+
33059
+ END OF TERMS AND CONDITIONS
33060
  --------------------------------------------------------------------------------
33061
  uuid
33062
 
build/web/flutter_bootstrap.js CHANGED
@@ -39,6 +39,6 @@ _flutter.buildConfig = {"engineRevision":"382be0028d370607f76215a9be322e5514b263
39
 
40
  _flutter.loader.load({
41
  serviceWorkerSettings: {
42
- serviceWorkerVersion: "3310482292"
43
  }
44
  });
 
39
 
40
  _flutter.loader.load({
41
  serviceWorkerSettings: {
42
+ serviceWorkerVersion: "2175777042"
43
  }
44
  });
build/web/flutter_service_worker.js CHANGED
@@ -3,11 +3,11 @@ const MANIFEST = 'flutter-app-manifest';
3
  const TEMP = 'flutter-temp-cache';
4
  const CACHE_NAME = 'flutter-app-cache';
5
 
6
- const RESOURCES = {"flutter_bootstrap.js": "ad3dd4404e2156ccb1734ec07b249cd5",
7
  "version.json": "b5eaae4fc120710a3c35125322173615",
8
  "index.html": "f34c56fffc6b38f62412a5db2315dec8",
9
  "/": "f34c56fffc6b38f62412a5db2315dec8",
10
- "main.dart.js": "92b9f48aec1daf04b5f8ee31dec89bf9",
11
  "flutter.js": "83d881c1dbb6d6bcd6b42e274605b69c",
12
  "favicon.png": "5dcef449791fa27946b3d35ad8803796",
13
  "icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
@@ -16,7 +16,7 @@ const RESOURCES = {"flutter_bootstrap.js": "ad3dd4404e2156ccb1734ec07b249cd5",
16
  "icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
17
  "manifest.json": "7dc942a630334c1017089988a6ca07d4",
18
  "assets/AssetManifest.json": "b2202b29892f6fb630f40ab2f4950300",
19
- "assets/NOTICES": "b8cc2b4edd5c5d6d738a8c9dca79e631",
20
  "assets/FontManifest.json": "dc3d03800ccca4601324923c0b1d6d57",
21
  "assets/AssetManifest.bin.json": "b6a02db76c67a9b7f4f2e1623f91dcb7",
22
  "assets/packages/cupertino_icons/assets/CupertinoIcons.ttf": "33b7d9392238c04c131b6ce224e13711",
 
3
  const TEMP = 'flutter-temp-cache';
4
  const CACHE_NAME = 'flutter-app-cache';
5
 
6
+ const RESOURCES = {"flutter_bootstrap.js": "87126968851498701a21880e28da0cfc",
7
  "version.json": "b5eaae4fc120710a3c35125322173615",
8
  "index.html": "f34c56fffc6b38f62412a5db2315dec8",
9
  "/": "f34c56fffc6b38f62412a5db2315dec8",
10
+ "main.dart.js": "6906a64b0fc86e1254324745be115bab",
11
  "flutter.js": "83d881c1dbb6d6bcd6b42e274605b69c",
12
  "favicon.png": "5dcef449791fa27946b3d35ad8803796",
13
  "icons/Icon-192.png": "ac9a721a12bbc803b44f645561ecb1e1",
 
16
  "icons/Icon-512.png": "96e752610906ba2a93c65f8abe1645f1",
17
  "manifest.json": "7dc942a630334c1017089988a6ca07d4",
18
  "assets/AssetManifest.json": "b2202b29892f6fb630f40ab2f4950300",
19
+ "assets/NOTICES": "88e46df57c7d48d6b68bd2505bf0e33d",
20
  "assets/FontManifest.json": "dc3d03800ccca4601324923c0b1d6d57",
21
  "assets/AssetManifest.bin.json": "b6a02db76c67a9b7f4f2e1623f91dcb7",
22
  "assets/packages/cupertino_icons/assets/CupertinoIcons.ttf": "33b7d9392238c04c131b6ce224e13711",
build/web/main.dart.js CHANGED
The diff for this file is too large to render. See raw diff
 
lib/main.dart CHANGED
@@ -1,9 +1,13 @@
1
  // lib/main.dart
2
  import 'package:aitube2/config/config.dart';
 
 
3
  import 'package:aitube2/services/settings_service.dart';
4
  import 'package:aitube2/services/websocket_api_service.dart';
5
  import 'package:aitube2/theme/colors.dart';
6
  import 'package:aitube2/widgets/maintenance_screen.dart';
 
 
7
  import 'package:flutter/material.dart';
8
  import 'screens/home_screen.dart';
9
  import 'services/cache_service.dart';
@@ -15,6 +19,7 @@ void main() async {
15
 
16
  Widget homeWidget = const HomeScreen();
17
  Exception? connectionError;
 
18
 
19
  try {
20
  // Initialize services in sequence to ensure proper dependencies
@@ -22,12 +27,52 @@ void main() async {
22
  await CacheService().initialize();
23
 
24
  // Initialize the WebSocket service
25
- final wsService = WebSocketApiService();
26
  await wsService.initialize();
27
 
28
  // Check the current status
29
  if (wsService.status == ConnectionStatus.maintenance || wsService.isInMaintenance) {
30
  homeWidget = const MaintenanceScreen(error: null);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  }
32
 
33
  // Listen to connection status changes
@@ -116,6 +161,11 @@ class AiTubeApp extends StatelessWidget {
116
  bodyMedium: TextStyle(color: AiTubeColors.onSurfaceVariant),
117
  ),
118
  ),
 
 
 
 
 
119
  home: home,
120
  );
121
  }
 
1
  // lib/main.dart
2
  import 'package:aitube2/config/config.dart';
3
+ import 'package:aitube2/models/video_result.dart';
4
+ import 'package:aitube2/screens/video_screen.dart';
5
  import 'package:aitube2/services/settings_service.dart';
6
  import 'package:aitube2/services/websocket_api_service.dart';
7
  import 'package:aitube2/theme/colors.dart';
8
  import 'package:aitube2/widgets/maintenance_screen.dart';
9
+ import 'package:aitube2/widgets/web_utils.dart';
10
+ import 'package:flutter/foundation.dart';
11
  import 'package:flutter/material.dart';
12
  import 'screens/home_screen.dart';
13
  import 'services/cache_service.dart';
 
19
 
20
  Widget homeWidget = const HomeScreen();
21
  Exception? connectionError;
22
+ final WebSocketApiService wsService = WebSocketApiService();
23
 
24
  try {
25
  // Initialize services in sequence to ensure proper dependencies
 
27
  await CacheService().initialize();
28
 
29
  // Initialize the WebSocket service
 
30
  await wsService.initialize();
31
 
32
  // Check the current status
33
  if (wsService.status == ConnectionStatus.maintenance || wsService.isInMaintenance) {
34
  homeWidget = const MaintenanceScreen(error: null);
35
+ } else if (kIsWeb) {
36
+ // Handle URL query parameters (web only)
37
+ final params = getUrlParameters();
38
+
39
+ // Handle search parameter
40
+ if (params.containsKey('search')) {
41
+ final searchQuery = params['search'] ?? '';
42
+ if (searchQuery.isNotEmpty) {
43
+ // Pass search query to HomeScreen - it will trigger search on load
44
+ homeWidget = HomeScreen(initialSearchQuery: searchQuery);
45
+ }
46
+ }
47
+ // Handle view parameter (higher priority than search if both are present)
48
+ else if (params.containsKey('view')) {
49
+ final viewQuery = params['view'] ?? '';
50
+ if (viewQuery.isNotEmpty) {
51
+ // Create a loading widget that will transition to VideoScreen once search completes
52
+ homeWidget = FutureBuilder<VideoResult>(
53
+ future: wsService.search(viewQuery),
54
+ builder: (context, snapshot) {
55
+ if (snapshot.connectionState == ConnectionState.done && snapshot.hasData) {
56
+ // Navigate to VideoScreen once we have the result
57
+ return VideoScreen(video: snapshot.data!);
58
+ } else if (snapshot.hasError) {
59
+ return Scaffold(
60
+ body: Center(
61
+ child: Text('Error loading video: ${snapshot.error}'),
62
+ ),
63
+ );
64
+ } else {
65
+ // Show loading indicator while waiting
66
+ return const Scaffold(
67
+ body: Center(
68
+ child: CircularProgressIndicator(),
69
+ ),
70
+ );
71
+ }
72
+ },
73
+ );
74
+ }
75
+ }
76
  }
77
 
78
  // Listen to connection status changes
 
161
  bodyMedium: TextStyle(color: AiTubeColors.onSurfaceVariant),
162
  ),
163
  ),
164
+ // Use custom route handling to support deep linking with URL parameters on web
165
+ onGenerateRoute: (settings) {
166
+ // The home screen is the default fallback
167
+ return MaterialPageRoute(builder: (_) => home);
168
+ },
169
  home: home,
170
  );
171
  }
lib/screens/home_screen.dart CHANGED
@@ -1,6 +1,8 @@
1
  // lib/screens/home_screen.dart
2
  import 'dart:async';
3
  import 'package:aitube2/config/config.dart';
 
 
4
  import 'package:flutter/material.dart';
5
  import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
6
  import 'package:aitube2/screens/video_screen.dart';
@@ -13,7 +15,12 @@ import 'package:aitube2/widgets/search_box.dart';
13
  import 'package:aitube2/theme/colors.dart';
14
 
15
  class HomeScreen extends StatefulWidget {
16
- const HomeScreen({super.key});
 
 
 
 
 
17
 
18
  @override
19
  State<HomeScreen> createState() => _HomeScreenState();
@@ -34,7 +41,19 @@ class _HomeScreenState extends State<HomeScreen> {
34
  super.initState();
35
  _initializeWebSocket();
36
  _setupSearchListener();
37
- _loadLastResults();
 
 
 
 
 
 
 
 
 
 
 
 
38
  }
39
 
40
  Future<void> _loadLastResults() async {
@@ -193,6 +212,11 @@ class _HomeScreenState extends State<HomeScreen> {
193
  _websocketService.stopContinuousSearch(_currentSearchQuery!);
194
  }
195
 
 
 
 
 
 
196
  try {
197
  // Check connection
198
  if (!_websocketService.isConnected) {
@@ -303,6 +327,14 @@ class _HomeScreenState extends State<HomeScreen> {
303
  return GestureDetector(
304
  onTap: () {
305
  _stopSearch(); // Stop search but keep results
 
 
 
 
 
 
 
 
306
  Navigator.push(
307
  context,
308
  MaterialPageRoute(
 
1
  // lib/screens/home_screen.dart
2
  import 'dart:async';
3
  import 'package:aitube2/config/config.dart';
4
+ import 'package:aitube2/widgets/web_utils.dart';
5
+ import 'package:flutter/foundation.dart';
6
  import 'package:flutter/material.dart';
7
  import 'package:flutter_staggered_grid_view/flutter_staggered_grid_view.dart';
8
  import 'package:aitube2/screens/video_screen.dart';
 
15
  import 'package:aitube2/theme/colors.dart';
16
 
17
  class HomeScreen extends StatefulWidget {
18
+ final String? initialSearchQuery;
19
+
20
+ const HomeScreen({
21
+ super.key,
22
+ this.initialSearchQuery,
23
+ });
24
 
25
  @override
26
  State<HomeScreen> createState() => _HomeScreenState();
 
41
  super.initState();
42
  _initializeWebSocket();
43
  _setupSearchListener();
44
+
45
+ // Check if we have an initial search query from URL parameters
46
+ if (widget.initialSearchQuery != null && widget.initialSearchQuery!.isNotEmpty) {
47
+ _searchController.text = widget.initialSearchQuery!;
48
+ // Need to use Future.delayed to ensure WebSocket is initialized
49
+ Future.delayed(const Duration(milliseconds: 500), () {
50
+ if (mounted) {
51
+ _search(widget.initialSearchQuery!);
52
+ }
53
+ });
54
+ } else {
55
+ _loadLastResults();
56
+ }
57
  }
58
 
59
  Future<void> _loadLastResults() async {
 
212
  _websocketService.stopContinuousSearch(_currentSearchQuery!);
213
  }
214
 
215
+ // Update URL parameter for web builds
216
+ if (kIsWeb) {
217
+ updateUrlParameter('search', trimmedQuery);
218
+ }
219
+
220
  try {
221
  // Check connection
222
  if (!_websocketService.isConnected) {
 
327
  return GestureDetector(
328
  onTap: () {
329
  _stopSearch(); // Stop search but keep results
330
+
331
+ // Update URL parameter on web platform
332
+ if (kIsWeb) {
333
+ // Update view parameter and remove search parameter
334
+ updateUrlParameter('view', _results[index].title);
335
+ removeUrlParameter('search');
336
+ }
337
+
338
  Navigator.push(
339
  context,
340
  MaterialPageRoute(
lib/screens/video_screen.dart CHANGED
@@ -1,6 +1,8 @@
1
  // lib/screens/video_screen.dart
2
  import 'package:aitube2/widgets/chat_widget.dart';
3
  import 'package:aitube2/widgets/search_box.dart';
 
 
4
  import 'package:flutter/material.dart';
5
  import '../config/config.dart';
6
  import '../models/video_result.dart';
@@ -101,6 +103,13 @@ class _VideoScreenState extends State<VideoScreen> {
101
  }
102
 
103
  setState(() => _isSearching = true);
 
 
 
 
 
 
 
104
 
105
  try {
106
  // First, cancel any requests for the current video
 
1
  // lib/screens/video_screen.dart
2
  import 'package:aitube2/widgets/chat_widget.dart';
3
  import 'package:aitube2/widgets/search_box.dart';
4
+ import 'package:aitube2/widgets/web_utils.dart';
5
+ import 'package:flutter/foundation.dart';
6
  import 'package:flutter/material.dart';
7
  import '../config/config.dart';
8
  import '../models/video_result.dart';
 
103
  }
104
 
105
  setState(() => _isSearching = true);
106
+
107
+ // Update URL parameter on web platform
108
+ if (kIsWeb) {
109
+ // Update view parameter and remove search parameter if present
110
+ updateUrlParameter('view', query);
111
+ removeUrlParameter('search');
112
+ }
113
 
114
  try {
115
  // First, cancel any requests for the current video
lib/services/null_html.dart ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /// Null implementation for html when not on web platform
2
+ /// This file is imported conditionally when not running on web
3
+
4
+ class Window {
5
+ final Document document = Document();
6
+ final History history = History();
7
+ final Location location = Location();
8
+
9
+ Stream<dynamic> get onBeforeUnload =>
10
+ Stream.fromIterable([]).asBroadcastStream();
11
+ }
12
+
13
+ class Document {
14
+ String get visibilityState => 'visible';
15
+
16
+ Stream<dynamic> get onVisibilityChange =>
17
+ Stream.fromIterable([]).asBroadcastStream();
18
+ }
19
+
20
+ class History {
21
+ void pushState(dynamic data, String title, String url) {
22
+ // No-op for non-web platforms
23
+ }
24
+ }
25
+
26
+ class Location {
27
+ String get href => '';
28
+ }
29
+
30
+ // Exported instances
31
+ final Window window = Window();
32
+ final Document document = Document();
lib/widgets/null_html.dart ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Mock implementations for non-web platforms
2
+
3
+ class Window {
4
+ final document = Document();
5
+ final history = History();
6
+ final location = Location();
7
+
8
+ Stream<dynamic> get onBeforeUnload =>
9
+ Stream.fromIterable([]).asBroadcastStream();
10
+ }
11
+
12
+ class Document {
13
+ String get visibilityState => 'visible';
14
+
15
+ Stream<dynamic> get onVisibilityChange =>
16
+ Stream.fromIterable([]).asBroadcastStream();
17
+ }
18
+
19
+ class History {
20
+ void pushState(dynamic data, String title, String url) {
21
+ // No-op for non-web platforms
22
+ }
23
+ }
24
+
25
+ class Location {
26
+ String get href => '';
27
+ }
28
+
29
+ // Exported instances
30
+ final window = Window();
31
+ final document = Document();
lib/widgets/search_box.dart CHANGED
@@ -30,7 +30,7 @@ class _SearchBoxState extends State<SearchBox> {
30
  List<String> _suggestions = [];
31
  OverlayEntry? _overlayEntry;
32
  final _layerLink = LayerLink();
33
- final bool _isComposing = false;
34
 
35
  @override
36
  void initState() {
@@ -51,7 +51,10 @@ class _SearchBoxState extends State<SearchBox> {
51
  }
52
 
53
  void _onSearchTextChanged() {
54
- if (_focusNode.hasFocus && !_isComposing) {
 
 
 
55
  _updateSuggestions();
56
  }
57
  }
@@ -154,6 +157,10 @@ class _SearchBoxState extends State<SearchBox> {
154
  _hideSuggestions();
155
  FocusScope.of(context).unfocus();
156
  widget.onSearch(trimmedValue);
 
 
 
 
157
  }
158
  }
159
 
 
30
  List<String> _suggestions = [];
31
  OverlayEntry? _overlayEntry;
32
  final _layerLink = LayerLink();
33
+ bool _isComposing = false;
34
 
35
  @override
36
  void initState() {
 
51
  }
52
 
53
  void _onSearchTextChanged() {
54
+ if (_focusNode.hasFocus) {
55
+ setState(() {
56
+ _isComposing = widget.controller.text.isNotEmpty;
57
+ });
58
  _updateSuggestions();
59
  }
60
  }
 
157
  _hideSuggestions();
158
  FocusScope.of(context).unfocus();
159
  widget.onSearch(trimmedValue);
160
+ // Reset _isComposing to ensure the field can be edited again
161
+ setState(() {
162
+ _isComposing = false;
163
+ });
164
  }
165
  }
166
 
lib/widgets/video_player_widget.dart CHANGED
@@ -3,12 +3,15 @@
3
  import 'dart:async';
4
  import 'package:aitube2/config/config.dart';
5
  import 'package:flutter/material.dart';
6
- import 'package:flutter/foundation.dart' show kDebugMode;
7
  import 'package:video_player/video_player.dart';
8
  import '../models/video_result.dart';
9
  import '../services/clip_queue_manager.dart';
10
  import '../theme/colors.dart';
11
 
 
 
 
12
  class VideoPlayerWidget extends StatefulWidget {
13
  final VideoResult video;
14
  final String? initialThumbnailUrl;
@@ -29,7 +32,7 @@ class VideoPlayerWidget extends StatefulWidget {
29
  State<VideoPlayerWidget> createState() => _VideoPlayerWidgetState();
30
  }
31
 
32
- class _VideoPlayerWidgetState extends State<VideoPlayerWidget> {
33
  late final ClipQueueManager _queueManager;
34
  VideoPlayerController? _currentController;
35
  VideoPlayerController? _nextController;
@@ -37,8 +40,8 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget> {
37
  bool _isPlaying = false;
38
  bool _isLoading = false;
39
  bool _isInitialLoad = true;
 
40
 
41
-
42
  double _loadingProgress = 0.0;
43
  Timer? _progressTimer;
44
  Timer? _debugTimer;
@@ -54,9 +57,61 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget> {
54
  @override
55
  void initState() {
56
  super.initState();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57
  _initializePlayer();
58
  // if (kDebugMode) { _startDebugPrinting(); }
59
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  void _startNextClipCheck() {
62
  _nextClipCheckTimer?.cancel();
@@ -223,14 +278,34 @@ class _VideoPlayerWidgetState extends State<VideoPlayerWidget> {
223
  }
224
  }
225
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
226
  @override
227
  void dispose() {
228
  _isDisposed = true;
 
 
 
 
229
  _currentController?.dispose();
230
  _nextController?.dispose();
231
  _progressTimer?.cancel();
232
  _debugTimer?.cancel();
233
- _playbackTimer?.cancel();
234
  _nextClipCheckTimer?.cancel();
235
  _positionTrackingTimer?.cancel();
236
  _queueManager.dispose();
 
3
  import 'dart:async';
4
  import 'package:aitube2/config/config.dart';
5
  import 'package:flutter/material.dart';
6
+ import 'package:flutter/foundation.dart' show kDebugMode, kIsWeb;
7
  import 'package:video_player/video_player.dart';
8
  import '../models/video_result.dart';
9
  import '../services/clip_queue_manager.dart';
10
  import '../theme/colors.dart';
11
 
12
+ // Conditionally import dart:html for web platform
13
+ import 'web_utils.dart' if (dart.library.html) 'dart:html' as html;
14
+
15
  class VideoPlayerWidget extends StatefulWidget {
16
  final VideoResult video;
17
  final String? initialThumbnailUrl;
 
32
  State<VideoPlayerWidget> createState() => _VideoPlayerWidgetState();
33
  }
34
 
35
+ class _VideoPlayerWidgetState extends State<VideoPlayerWidget> with WidgetsBindingObserver {
36
  late final ClipQueueManager _queueManager;
37
  VideoPlayerController? _currentController;
38
  VideoPlayerController? _nextController;
 
40
  bool _isPlaying = false;
41
  bool _isLoading = false;
42
  bool _isInitialLoad = true;
43
+ bool _wasPlayingBeforeBackground = false;
44
 
 
45
  double _loadingProgress = 0.0;
46
  Timer? _progressTimer;
47
  Timer? _debugTimer;
 
57
  @override
58
  void initState() {
59
  super.initState();
60
+
61
+ // Register as an observer to detect app lifecycle changes
62
+ WidgetsBinding.instance.addObserver(this);
63
+
64
+ // Add web-specific visibility change listener
65
+ if (kIsWeb) {
66
+ // These handlers only run on web platforms
67
+ try {
68
+ // Add document visibility change listener
69
+ html.document.onVisibilityChange.listen((_) {
70
+ _handleVisibilityChange();
71
+ });
72
+
73
+ // Add before unload listener
74
+ html.window.onBeforeUnload.listen((_) {
75
+ // Pause video when navigating away from the page
76
+ _pauseVideo();
77
+ });
78
+ } catch (e) {
79
+ debugPrint('Error setting up web visibility listeners: $e');
80
+ }
81
+ }
82
+
83
  _initializePlayer();
84
  // if (kDebugMode) { _startDebugPrinting(); }
85
  }
86
+
87
+ void _handleVisibilityChange() {
88
+ if (!kIsWeb) return;
89
+
90
+ try {
91
+ final visibilityState = html.window.document.visibilityState;
92
+ if (visibilityState == 'hidden') {
93
+ _pauseVideo();
94
+ } else if (visibilityState == 'visible' && _wasPlayingBeforeBackground) {
95
+ _resumeVideo();
96
+ }
97
+ } catch (e) {
98
+ debugPrint('Error handling visibility change: $e');
99
+ }
100
+ }
101
+
102
+ void _pauseVideo() {
103
+ if (_isPlaying) {
104
+ _wasPlayingBeforeBackground = true;
105
+ _togglePlayback();
106
+ }
107
+ }
108
+
109
+ void _resumeVideo() {
110
+ if (!_isPlaying && _wasPlayingBeforeBackground) {
111
+ _wasPlayingBeforeBackground = false;
112
+ _togglePlayback();
113
+ }
114
+ }
115
 
116
  void _startNextClipCheck() {
117
  _nextClipCheckTimer?.cancel();
 
278
  }
279
  }
280
 
281
+ @override
282
+ void didChangeAppLifecycleState(AppLifecycleState state) {
283
+ super.didChangeAppLifecycleState(state);
284
+
285
+ // Handle app lifecycle changes for native platforms
286
+ if (!kIsWeb) {
287
+ if (state == AppLifecycleState.paused ||
288
+ state == AppLifecycleState.inactive ||
289
+ state == AppLifecycleState.detached) {
290
+ _pauseVideo();
291
+ } else if (state == AppLifecycleState.resumed && _wasPlayingBeforeBackground) {
292
+ _resumeVideo();
293
+ }
294
+ }
295
+ }
296
+
297
  @override
298
  void dispose() {
299
  _isDisposed = true;
300
+
301
+ // Unregister the observer
302
+ WidgetsBinding.instance.removeObserver(this);
303
+
304
  _currentController?.dispose();
305
  _nextController?.dispose();
306
  _progressTimer?.cancel();
307
  _debugTimer?.cancel();
308
+ _playbackTimer?.cancel();
309
  _nextClipCheckTimer?.cancel();
310
  _positionTrackingTimer?.cancel();
311
  _queueManager.dispose();
lib/widgets/web_utils.dart ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import 'dart:async';
2
+ import 'package:flutter/foundation.dart';
3
+
4
+ // Platform-specific imports handling
5
+ import 'package:universal_html/html.dart' if (dart.library.io) 'package:aitube2/widgets/null_html.dart' as html;
6
+
7
+ /// Get URL parameters from the current URL (web only)
8
+ Map<String, String> getUrlParameters() {
9
+ if (!kIsWeb) return {};
10
+
11
+ final uri = Uri.parse(html.window.location.href);
12
+ return uri.queryParameters;
13
+ }
14
+
15
+ /// Update URL parameters without page reload (web only)
16
+ void updateUrlParameter(String key, String value) {
17
+ if (!kIsWeb) return;
18
+
19
+ final uri = Uri.parse(html.window.location.href);
20
+ final params = Map<String, String>.from(uri.queryParameters);
21
+
22
+ // Update the parameter
23
+ params[key] = value;
24
+
25
+ // Create a new URL with updated parameters
26
+ final newUri = uri.replace(queryParameters: params);
27
+
28
+ // Update browser history without reloading the page
29
+ html.window.history.pushState(null, '', newUri.toString());
30
+ }
31
+
32
+ /// Remove a URL parameter without page reload (web only)
33
+ void removeUrlParameter(String key) {
34
+ if (!kIsWeb) return;
35
+
36
+ final uri = Uri.parse(html.window.location.href);
37
+ final params = Map<String, String>.from(uri.queryParameters);
38
+
39
+ // Remove the parameter
40
+ params.remove(key);
41
+
42
+ // Create a new URL with updated parameters
43
+ final newUri = uri.replace(queryParameters: params);
44
+
45
+ // Update browser history without reloading the page
46
+ html.window.history.pushState(null, '', newUri.toString());
47
+ }
48
+
49
+ /// Fallback implementation for non-web platforms
50
+ class NullHtml {
51
+ // Mock objects to prevent build errors
52
+ final window = Window();
53
+ final document = Document();
54
+ }
55
+
56
+ // Mock implementation for html.window
57
+ class Window {
58
+ final document = Document();
59
+ final History history = History();
60
+
61
+ Stream<dynamic> get onBeforeUnload =>
62
+ Stream.fromIterable([]).asBroadcastStream();
63
+
64
+ String get location => '';
65
+ }
66
+
67
+ // Mock implementation for html.History
68
+ class History {
69
+ void pushState(dynamic data, String title, String url) {
70
+ // No-op for non-web platforms
71
+ }
72
+ }
73
+
74
+ // Mock implementation for html.document
75
+ class Document {
76
+ String get visibilityState => 'visible';
77
+
78
+ Stream<dynamic> get onVisibilityChange =>
79
+ Stream.fromIterable([]).asBroadcastStream();
80
+ }
pubspec.lock CHANGED
@@ -25,6 +25,14 @@ packages:
25
  url: "https://pub.dev"
26
  source: hosted
27
  version: "1.4.0"
 
 
 
 
 
 
 
 
28
  clock:
29
  dependency: transitive
30
  description:
@@ -501,6 +509,22 @@ packages:
501
  url: "https://pub.dev"
502
  source: hosted
503
  version: "1.4.0"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  url_launcher:
505
  dependency: "direct main"
506
  description:
 
25
  url: "https://pub.dev"
26
  source: hosted
27
  version: "1.4.0"
28
+ charcode:
29
+ dependency: transitive
30
+ description:
31
+ name: charcode
32
+ sha256: fb0f1107cac15a5ea6ef0a6ef71a807b9e4267c713bb93e00e92d737cc8dbd8a
33
+ url: "https://pub.dev"
34
+ source: hosted
35
+ version: "1.4.0"
36
  clock:
37
  dependency: transitive
38
  description:
 
509
  url: "https://pub.dev"
510
  source: hosted
511
  version: "1.4.0"
512
+ universal_html:
513
+ dependency: "direct main"
514
+ description:
515
+ name: universal_html
516
+ sha256: "56536254004e24d9d8cfdb7dbbf09b74cf8df96729f38a2f5c238163e3d58971"
517
+ url: "https://pub.dev"
518
+ source: hosted
519
+ version: "2.2.4"
520
+ universal_io:
521
+ dependency: transitive
522
+ description:
523
+ name: universal_io
524
+ sha256: "1722b2dcc462b4b2f3ee7d188dad008b6eb4c40bbd03a3de451d82c78bba9aad"
525
+ url: "https://pub.dev"
526
+ source: hosted
527
+ version: "2.2.2"
528
  url_launcher:
529
  dependency: "direct main"
530
  description:
pubspec.yaml CHANGED
@@ -51,6 +51,7 @@ dependencies:
51
  idb_shim: ^2.6.1+7
52
  synchronized: ^3.3.0+3
53
  async: ^2.11.0
 
54
 
55
  dev_dependencies:
56
  flutter_test:
 
51
  idb_shim: ^2.6.1+7
52
  synchronized: ^3.3.0+3
53
  async: ^2.11.0
54
+ universal_html: ^2.2.4
55
 
56
  dev_dependencies:
57
  flutter_test: