prasanth.thangavel commited on
Commit
a219c8e
·
1 Parent(s): 4c3a0ee

Update README.md and app.py

Browse files
Files changed (2) hide show
  1. README.md +27 -1
  2. app.py +10 -10
README.md CHANGED
@@ -9,5 +9,31 @@ python_version: 3.11.5
9
  app_file: app.py
10
  pinned: false
11
  ---
 
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  app_file: app.py
10
  pinned: false
11
  ---
12
+ # <span style='display: flex; align-items: center; gap: 10px;'><img src='https://cdn-icons-png.flaticon.com/512/1384/1384060.png' width='25'/> <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Youtube_Music_icon.svg/2048px-Youtube_Music_icon.svg.png' width='25'/>YouTube Downloader</span>
13
 
14
+ This application uses
15
+ - [`yt_dlp`](https://github.com/yt-dlp/yt-dlp) - For downloading Audio/Video from YouTube and YoutTube Music.
16
+ - HF [`gradio`](https://www.gradio.app/) - For UI.
17
+
18
+ ## Cookies setup details
19
+ *Note: This setup is only needed if running in hugging face (HF) spaces to avoid bot related errors*
20
+
21
+ 1. **Download the YouTube Cookies**
22
+ - Follow the instruction provided [here](https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies) to download the YouTube cookies.
23
+ - Rename the downloaded cookie as `cookies.firefox-private.txt` and place it in the current working directory
24
+ 2. **Convert cookie file content to `.env` file**
25
+ - Simple copy paste will not work due to special characters
26
+ - So, we will use the `cookies_to_env` function.
27
+ - Uncomment the `# Convert cookie file to env and save locally` section and run the code
28
+ - Remember to comment the code once the `.env` file is updated.
29
+ 3. **Set up or Update the Secrets in HF**
30
+ - Copy the the `.env` content (only the value, and not the key) and paste it inside the Secrets (Private) > `FIREFOX_COOKIES` in Hugging Face space.
31
+ 4. **Deploy the changes to HF space, and Voila!**
32
+
33
+ ## `.env` file structure
34
+ ```
35
+ FIREFOX_COOKIES="<Formatted_Cookie_Content_Goes_Here>"
36
+ ```
37
+
38
+ ## Additional resources
39
+ - Check out the configuration (and README metadata) reference [here](https://huggingface.co/docs/hub/spaces-config-reference)
app.py CHANGED
@@ -60,7 +60,7 @@ def env_to_cookies_from_env(output_file: str) -> None:
60
  try:
61
  load_dotenv() # Load from .env file
62
  env_content = os.getenv('FIREFOX_COOKIES')
63
- print(f"Printing env content: \n{env_content}")
64
  if not env_content:
65
  raise ValueError("FIREFOX_COOKIES not found in .env file")
66
 
@@ -161,17 +161,17 @@ def download_for_browser(url, mode='audio', quality='high'):
161
  def create_browser_ui():
162
 
163
  with gr.Blocks(title="YouTube Downloader", theme=gr.themes.Soft()) as demo:
164
- gr.Markdown("## YouTube Downloader")
 
165
 
166
  with gr.Row():
167
- url_input = gr.Textbox(
 
168
  label="YouTube URL",
169
  placeholder="https://youtube.com/watch?v=...",
170
- scale=2
171
- )
172
-
173
- with gr.Row():
174
- with gr.Column(scale=1):
175
  mode_input = gr.Radio(
176
  choices=["audio", "video"],
177
  value="audio",
@@ -183,9 +183,9 @@ def create_browser_ui():
183
  label="Quality"
184
  )
185
 
186
- download_button = gr.Button("Convert", variant="primary")
187
 
188
- with gr.Column(scale=2):
189
  status_text = gr.Textbox(label="Converting Status", interactive=False)
190
  output_file = gr.File(label="Download to your device ...")
191
 
 
60
  try:
61
  load_dotenv() # Load from .env file
62
  env_content = os.getenv('FIREFOX_COOKIES')
63
+ #print(f"Printing env content: \n{env_content}")
64
  if not env_content:
65
  raise ValueError("FIREFOX_COOKIES not found in .env file")
66
 
 
161
  def create_browser_ui():
162
 
163
  with gr.Blocks(title="YouTube Downloader", theme=gr.themes.Soft()) as demo:
164
+
165
+ gr.Markdown("""## <span style='display: flex; align-items: center; gap: 10px;'><img src='https://cdn-icons-png.flaticon.com/512/1384/1384060.png' width='25'/> <img src='https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/Youtube_Music_icon.svg/2048px-Youtube_Music_icon.svg.png' width='25'/>YouTube Downloader</span>""")
166
 
167
  with gr.Row():
168
+ with gr.Column(scale=1):
169
+ url_input = gr.Textbox(
170
  label="YouTube URL",
171
  placeholder="https://youtube.com/watch?v=...",
172
+ scale=1
173
+ )
174
+
 
 
175
  mode_input = gr.Radio(
176
  choices=["audio", "video"],
177
  value="audio",
 
183
  label="Quality"
184
  )
185
 
186
+ download_button = gr.Button("Convert", variant="primary")
187
 
188
+ with gr.Column(scale=1):
189
  status_text = gr.Textbox(label="Converting Status", interactive=False)
190
  output_file = gr.File(label="Download to your device ...")
191