V2N_In-Android

This is the Python Backend for V2N feature for android

0
0
0
Python
public

StudyOS - YouTube Video to Smart Notes (Minimal Working Prototype)

This workspace contains one complete feature:

  • Android app sends YouTube URL
  • Flask backend fetches transcript
  • Backend performs local extractive NLP summarization (no external AI APIs)
  • Backend returns structured notes for Retrofit

1. Folder structure

V2N_Demo/
├── backend/
│   ├── app.py
│   ├── summarizer.py
│   ├── youtube_utils.py
│   ├── requirements.txt
│   └── README.md
└── android-feature/
    ├── build-gradle-snippets.txt
    └── app/
        └── src/
            └── main/
                ├── AndroidManifest.xml
                ├── java/com/studyos/notes/
                │   ├── model/
                │   │   ├── SummarizeRequest.kt
                │   │   └── SummarizeResponse.kt
                │   ├── network/
                │   │   ├── RetrofitClient.kt
                │   │   └── StudyOsApi.kt
                │   └── ui/
                │       └── SmartNotesActivity.kt
                └── res/layout/
                    └── activity_smart_notes.xml

2. Backend setup (Flask)

From workspace root:

cd backend
python3 -m venv ../.venv
source ../.venv/bin/activate
pip install -r requirements.txt
python app.py

Server runs on:

  • http://127.0.0.1:5000
  • http://<your-laptop-ip>:5000

Health check:

curl http://127.0.0.1:5000/health

Summarize test:

curl -X POST http://127.0.0.1:5000/summarize \
  -H "Content-Type: application/json" \
  -d '{"url":"https://www.youtube.com/watch?v=jNQXAC9IVRw"}'

Expected response shape:

{
  "summary": "...",
  "key_points": ["...", "..."]
}

3. Android integration (Retrofit)

Copy files from android-feature/app/src/main/... into your Android project module.

Add dependencies from android-feature/build-gradle-snippets.txt into your module build.gradle.

Make sure your manifest has internet permission:

<uses-permission android:name="android.permission.INTERNET" />

Use SmartNotesActivity as your screen (launch directly or navigate from your existing app).

4. Connect emulator/phone to local Flask server

Android emulator

In RetrofitClient.kt, keep:

  • BASE_URL = "http://10.0.2.2:5000/"

10.0.2.2 maps emulator -> host machine localhost.

Physical Android phone (same Wi-Fi)

  1. Find laptop local IP (Linux):
    • ip a (example: 192.168.1.78)
  2. Update BASE_URL in RetrofitClient.kt:
    • http://192.168.1.78:5000/
  3. Run Flask with host 0.0.0.0 (already configured in app.py).
  4. Ensure firewall allows port 5000.

5. API contract for Retrofit

Request:

{
  "url": "https://www.youtube.com/watch?v=..."
}

Success response:

{
  "summary": "...",
  "key_points": ["...", "..."]
}

Error response example:

{
  "error": "Transcript not available for this video"
}

6. Common errors and fixes

  1. Invalid YouTube URL
  • Fix: Use full valid YouTube link or raw 11-char video ID.
  1. Transcript not available for this video
  • Cause: Creator disabled captions or no transcript exists.
  • Fix: Test with another video that has captions.
  1. Network error in Android
  • Emulator: confirm 10.0.2.2 is used.
  • Phone: use laptop IP, not localhost.
  • Confirm Flask server is running.
  1. Failed to fetch transcript
  • Usually temporary YouTube/network issue.
  • Fix: retry, check internet, update package:
    • pip install -U youtube-transcript-api
  1. Android cleartext HTTP blocked (Android 9+)
  • Included in this prototype:
    • AndroidManifest.xml has usesCleartextTraffic=true
    • res/xml/network_security_config.xml allows cleartext traffic

7. Why this meets your constraints

  • No paid APIs
  • No external LLM APIs
  • Uses local NLP extractive summarization
  • Simple Flask + Retrofit architecture
  • Verified backend endpoint response on local machine
  • Minimal and demo-friendly
v0.3.3[beta]