{"id":31021891,"url":"https://github.com/anoushk1234/plex-screen-time","last_synced_at":"2025-09-13T11:49:14.907Z","repository":{"id":299594380,"uuid":"1003493480","full_name":"anoushk1234/plex-screen-time","owner":"anoushk1234","description":"Linux utility scripts for limiting Plex usage","archived":false,"fork":false,"pushed_at":"2025-06-27T12:23:22.000Z","size":31,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-09T22:27:02.624Z","etag":null,"topics":["plex","plex-media-server","plex-server","python","tautulli"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/anoushk1234.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-17T08:27:14.000Z","updated_at":"2025-06-27T12:23:25.000Z","dependencies_parsed_at":"2025-06-24T10:48:34.066Z","dependency_job_id":"d0cd1b38-3982-4352-a702-e92290151e1b","html_url":"https://github.com/anoushk1234/plex-screen-time","commit_stats":null,"previous_names":["anoushk1234/no-plex","anoushk1234/plex-screen-time"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/anoushk1234/plex-screen-time","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoushk1234%2Fplex-screen-time","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoushk1234%2Fplex-screen-time/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoushk1234%2Fplex-screen-time/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoushk1234%2Fplex-screen-time/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anoushk1234","download_url":"https://codeload.github.com/anoushk1234/plex-screen-time/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anoushk1234%2Fplex-screen-time/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274956258,"owners_count":25380670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["plex","plex-media-server","plex-server","python","tautulli"],"created_at":"2025-09-13T11:49:13.309Z","updated_at":"2025-09-13T11:49:14.895Z","avatar_url":"https://github.com/anoushk1234.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# no-plex\n\n`no-plex` is a daemon that monitors Plex sessions via the Tautulli API and automatically terminates streams based on configurable limits similar to Apple's Screen Time. It helps you enforce intentional media usage by restricting watch time per session, per day, and across specific hours so you can reduce passive consumption and gain focus.\n\nUnlike existing solutions (e.g. JBOPS), it actively monitors stream duration and forcefully terminates sessions once limits are exceeded — even mid-playback.\n\n## Features\n\n- Session enforcement:\n  - Daily total watch time limit (e.g., 60 minutes)\n  - Per-session watch limit (e.g., 30 minutes max per session)\n- Time-of-day blocking (e.g., restrict streaming between 10:30 PM and 1:00 PM)\n- SQLite-based session tracking so sessions are tracked even while watching unlike JBOPS.\n- Includes one off day( Sunday )\n- Accounts for playback pauses and buffering.\n- Systemd + timer-based execution every 5 seconds so it works even with reboots.\n\n## Requirements\n\n- Plex Media Server\n- [Tautulli](https://github.com/Tautulli/Tautulli) (API access enabled)\n- Python 3.9+\n- Linux system with `systemd`\n- `flock`, `iptables`, `sqlite3` (all standard on most distros)\n\n## Setup\n\n### 1. Clone the repository\n\n```bash\ngit clone https://github.com/anoushk1234/no-plex.git\ncd no-plex\nchmod +x plex-limit-state.py plex_limit_wrapper.sh\n```\n\n### 2. Configure Environment\n\nCopy `.env.example` to `.env`:\n\n```bash\ncp .env.example .env\n```\n\nEdit `.env` and set:\n\n- `TAUTULLI_URL`: your local or remote Tautulli API URL (e.g. `http://127.0.0.1:8181`)\n- `TAUTULLI_API_KEY`: your Tautulli API key\n- `KILL_MESSAGE`: Optional, The message shown when your stream is killed.\n- `MAX_TOTAL_MINUTES`: total watch time allowed per day\n- `MAX_SESSION_DURATION_MINUTES`: maximum allowed per-session duration\n- `ENABLE_BEDTIME`: Optional to block plex during sleep time\n\nThese values are loaded automatically by `plex-limit-state.py`.\n\n## Configure systemd\n\n### 1. Edit `plex_limit_wrapper.sh`\n\nUpdate the path:\n\n```bash\n/usr/bin/python3 /absolute/path/to/no-plex/plex-limit-state.py\n```\n\nMake it executable:\n\n```bash\nchmod +x plex_limit_wrapper.sh\n```\n\n### 2. Install the systemd service\n\nUpdate `ExecStart` in `plex-limit.service` to point to the absolute path of `plex_limit_wrapper.sh`.\n\n```ini\nExecStart=/home/youruser/no-plex/plex_limit_wrapper.sh\n```\n\nThen:\n\n```bash\nsudo cp plex-limit.service /etc/systemd/system/\nsudo systemctl daemon-reexec\nsudo systemctl enable plex-limit.service\n```\n\n### 3. Configure the timer\n\nThe timer is already configured to run every 5 seconds:\n\n```ini\n[Timer]\nOnBootSec=2min\nOnUnitActiveSec=5s\nAccuracySec=1s\nPersistent=false\n```\n\nInstall:\n\n```bash\nsudo cp plex-limit.timer /etc/systemd/system/\nsudo systemctl daemon-reexec\nsudo systemctl enable plex-limit.timer\nsudo systemctl start plex-limit.timer\n```\n\n## Optional: Bedtime Limit\nIf you want to turn off Plex usage during certain times set:\n```.env\nENABLE_BEDTIME=1\n```\n\nThe default time is 10:30 PM to 1:00pm but you can change it here:\n```py\ndef is_blocked_time():\n    now = datetime.now().time()\n    return now \u003e= dtime(22, 30) or now \u003c dtime(13, 0) # Change time here\n```\n\n## Debugging\n\n- Log file:  \n  `plex_session_tracker.log` (in the script directory)\n\n- SQLite database for sessions:  \n  `plex_session_tracker.db` (also local)\n\nThese files are created automatically.\n\n## Cleanup and Session Accuracy\n\nAt 23:59 daily, old session data is purged to allow accurate tracking the next day. Session duration is measured and stored even if playback is interrupted or restarted. \n\nThe script correctly handles cases where Plex reuses the same session ID or media `rating_key` by using composite keys and time delta validation.\n\n## License\n\nMIT License. See `LICENSE` file for details.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanoushk1234%2Fplex-screen-time","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanoushk1234%2Fplex-screen-time","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanoushk1234%2Fplex-screen-time/lists"}