{"id":19846525,"url":"https://github.com/hekmon/plexwebhooks","last_synced_at":"2025-05-01T21:31:15.183Z","repository":{"id":51325078,"uuid":"185040477","full_name":"hekmon/plexwebhooks","owner":"hekmon","description":"Golang bindings for Plex Webhooks","archived":false,"fork":false,"pushed_at":"2021-05-15T07:25:25.000Z","size":60,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-06-21T00:13:32.731Z","etag":null,"topics":["bindings","golang","golang-library","library","plex","plex-media-server","webhook","webhooks"],"latest_commit_sha":null,"homepage":"","language":"Go","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/hekmon.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}},"created_at":"2019-05-05T14:15:58.000Z","updated_at":"2024-06-21T00:13:32.732Z","dependencies_parsed_at":"2022-09-25T20:11:20.716Z","dependency_job_id":null,"html_url":"https://github.com/hekmon/plexwebhooks","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hekmon%2Fplexwebhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hekmon%2Fplexwebhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hekmon%2Fplexwebhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hekmon%2Fplexwebhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hekmon","download_url":"https://codeload.github.com/hekmon/plexwebhooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224278438,"owners_count":17285080,"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","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":["bindings","golang","golang-library","library","plex","plex-media-server","webhook","webhooks"],"created_at":"2024-11-12T13:11:44.300Z","updated_at":"2024-11-12T13:11:44.377Z","avatar_url":"https://github.com/hekmon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Plex Webhooks\n\n[![Go Reference](https://pkg.go.dev/badge/github.com/hekmon/plexwebhooks.svg)](https://pkg.go.dev/github.com/hekmon/plexwebhooks) [![Go Report Card](https://goreportcard.com/badge/github.com/hekmon/plexwebhooks)](https://goreportcard.com/report/github.com/hekmon/plexwebhooks)\n\nGolang binding for [Plex Webhooks](https://support.plex.tv/articles/115002267687-webhooks/).\n\nThis library provides:\n\n* Golang binding for webhook (JSON) payloads\n* Auto convert values to Golang types when possible (time, duration, IP, URL, etc...)\n* Multipart reader extractor which returns the hook payload and the thumbnail if present\n\n## Example\n\n```go\npackage main\n\nimport (\n    \"fmt\"\n    \"net/http\"\n    \"time\"\n\n    \"github.com/hekmon/plexwebhooks\"\n)\n\nfunc main() {\n    http.HandleFunc(\"/\", processHandler)\n    http.ListenAndServe(\":7095\", http.DefaultServeMux)\n}\n\nfunc processHandler(w http.ResponseWriter, r *http.Request) {\n    defer r.Body.Close()\n    // Create the multi part reader\n    multiPartReader, err := r.MultipartReader()\n    if err != nil {\n        // Detect error type for the http answer\n        if err == http.ErrNotMultipart || err == http.ErrMissingBoundary {\n            w.WriteHeader(http.StatusBadRequest)\n        } else {\n            w.WriteHeader(http.StatusInternalServerError)\n        }\n        // Try to write the error as http body\n        _, wErr := w.Write([]byte(err.Error()))\n        if wErr != nil {\n            err = fmt.Errorf(\"request error: %v | write error: %v\", err, wErr)\n        }\n        // Log the error\n        fmt.Println(\"can't create a multipart reader from request:\", err)\n        return\n    }\n    // Use the multipart reader to parse the request body\n    payload, thumb, err := plexwebhooks.Extract(multiPartReader)\n    if err != nil {\n        w.WriteHeader(http.StatusInternalServerError)\n        // Try to write the error as http body\n        _, wErr := w.Write([]byte(err.Error()))\n        if wErr != nil {\n            err = fmt.Errorf(\"request error: %v | write error: %v\", err, wErr)\n        }\n        // Log the error\n        fmt.Println(\"can't create a multipart reader from request:\", err)\n        return\n    }\n    // Do something\n    fmt.Println()\n    fmt.Println(time.Now())\n    fmt.Printf(\"%+v\\n\", *payload)\n    if thumb != nil {\n        fmt.Printf(\"Name: %s | Size: %d\\n\", thumb.Filename, len(thumb.Data))\n    }\n    fmt.Println()\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhekmon%2Fplexwebhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhekmon%2Fplexwebhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhekmon%2Fplexwebhooks/lists"}