xTeVe Documentation

repository·master·Indexed 22 days ago

https://github.com/xteve-project/xteve

xTeVe is an M3U proxy designed to provide Live TV support to Plex DVR and Emby Live TV. It manages M3U and XMLTV files, allows for channel filtering and mapping, and provides a buffered stream compatible with Plex and Emby EPG. The software can be installed via 64-bit binaries for Windows, macOS, Linux, and FreeBSD, or through various Docker images.

Tokens
6K
Snippets
8
Records
39
Agent score
81%

What's inside xTeVe

  1. Build xTeVe from source code

    master

    To build xTeVe from source, you need Go (version 1.16.2 or newer) installed.

    Build Steps

    1. Download the source code.
    2. Install the required dependencies:
      go get github.com/koron/go-ssdp
      go get github.com/gorilla/websocket
      go get github.com/kardianos/osext
    3. Build the binary:
      go build xteve.go
    go build xteve.go
  2. Install xTeVe via Docker or Binary

    master

    xTeVe is an M3U proxy for Plex DVR and Emby Live TV. You can install it using pre-compiled 64-bit binaries or via Docker containers.

    Binary Downloads (64-bit only)

    • Windows, macOS, Linux, or FreeBSD (Intel/AMD)
    • Linux (ARM64)

    Docker Images

    Several Docker images are available on Docker Hub, some including additional tools:

    • alturismo/xteve: Standard image.
    • alturismo/xteve_guide2go: Includes Guide2go (XMLTV grabber for Schedules Direct).
    • alturismo/xteve_g2g_owi: Includes Guide2go and owi2plex (XMLTV grabber for Enigma receivers).
    • dnsforge/xteve: Includes Guide2go, Zap2XML (Perl-based grabber), Bash, Crond, and Perl.
  3. Switch between xTeVe master and beta branches

    master

    The beta branch contains new features and bug fixes that have not yet been merged into the master branch. It is not recommended for production use.

    You can switch branches using the -branch command-line argument when starting xTeVe via the terminal.

    Note: When a branch is changed, an update is only performed if a new version is available and the update function is enabled in the xTeVe settings.

  4. Understand the DataStruct organization

    master

    The DataStruct represents the core internal state of xTeVe, containing the processed lineup and EPG data. It is organized into:

    • Cache: Contains image caches (Images), streaming URL mappings (StreamingURLS), and XMLTV data (XMLTV).
    • Filter: An array of Filter objects applied to the data.
    • Playlist: Contains M3U group information (Groups.Text and Groups.Value).
    • Streams: Lists of Active, All, and Inactive streams.
    • XMLTV: A collection of Files and a Mapping object for EPG data.
    • XEPG: A map of Channels and the total XEPGCount.
  5. Configure xTeVe settings via settings.json

    master

    The SettingsStruct defines the schema for the settings.json configuration file. Key configuration areas include:

    • Authentication: Control access for different interfaces using api, authentication.api, authentication.m3u, authentication.pms, authentication.web, and authentication.xml.
    • Buffer Settings: Configure streaming stability with buffer (type), buffer.size.kb, and buffer.timeout.
    • Media Players: Specify paths and options for external players using ffmpeg.path, ffmpeg.options, vlc.path, and vlc.options.
    • Files: Define source files via file (M3U slices) and xmltv (XMLTV slices).
    • System: Set the server port, ssdp (discovery), tuner count, and temp.path.
  6. Requirements for Plex and Emby integration

    master

    To use xTeVe with Plex or Emby, ensure you meet the following requirements:

    Plex Requirements

    • Plex Media Server (version 1.11.1.4730 or newer)
    • Plex Client with DVR support
    • Plex Pass subscription

    Emby Requirements

    • Emby Server (version 3.5.3.0 or newer)
    • Emby Client with Live-TV support
    • Emby Premiere subscription
  7. Use the xTeVe API

    master

    The xTeVe API allows programmatic interaction with the server via POST requests to the /api/ endpoint.

    Authentication

    1. Without Authentication: If Settings.API is enabled but Settings.AuthenticationAPI is false, you can send commands directly.
    2. With Authentication: If Settings.AuthenticationAPI is enabled, you must first log in to obtain a token.
      • Every API response contains a new token.
      • Tokens are valid for 60 minutes.
      • Include the token in subsequent requests using the token field in the JSON body.

    Common Commands

    • login: Authenticate using username and password to receive a token.
    • status: Returns server version, active/total streams, EPG source, and URLs for M3U and XMLTV.
    • update.m3u: Triggers an update of the M3U provider data and rebuilds the DVR database.
    • update.hdhr: Triggers an update of HDHR provider data.
    • update.xmltv: Triggers an update of XMLTV provider data.
    • update.xepg: Triggers an XEPG build.

    Example: Login and Status

  8. Check for the latest version using GetVersion

    master
    Call GetVersion() to request version information from the configured update server. This function sets the internal command to getVersion, performs a POST request to the Updater.URL with the client's metadata, and populates Updater.Response with the server's response. If successful, Updater.Response will contain the latest version string and potential download URLs.
  9. Stream media via the /stream/ endpoint

    master

    The /stream/ endpoint provides access to individual channel streams.

    Buffering and UDPxy

    • Buffering: If Settings.Buffer is set to xteve, xTeVe will buffer the stream. If set to -, xTeVe will perform a 302 redirect, allowing the client to connect directly to the source stream.
    • UDPxy: If Settings.UDPxy is configured and the stream is a multicast UDP stream (starting with udp://@), xTeVe rewrites the URL to point to the UDPxy host (e.g., http://<UDPxy_HOST>/udp/<STREAM_PATH>/).

    Limitations

    • RTSP and RTP streams are not supported when buffering is enabled.
  10. Manage users in the authentication system

    master

    The authentication package provides several methods to manage user accounts:

    • CreateDefaultUser(username, password): Creates a single default user. Returns an error if a user already exists.
    • CreateNewUser(username, password): Creates a new user with the provided credentials. Returns the new userID and an error if the user already exists.
    • RemoveUser(userID): Deletes the user associated with the given userID.
    • ChangeCredentials(userID, username, password): Updates the username or password for an existing user. Pass empty strings to leave a field unchanged.
  11. Authenticate users and manage sessions

    master

    Authentication is handled via tokens. A successful login returns a token that must be used for subsequent requests.

    • UserAuthentication(username, password): Validates credentials and returns a session token.
    • CheckTheValidityOfTheToken(token): Validates a token. If valid, it returns a newToken (rotating the token) to extend the session. If expired, it returns an error.
    • GetUserID(token): Retrieves the userID associated with a valid token.
    • CheckTheValidityOfTheTokenFromHTTPHeader(w, r): A helper for HTTP servers. It checks for a Token cookie in the request *http.Request, validates it, and uses SetCookieToken to update the response http.ResponseWriter with a new token.
  12. Initialize the authentication system

    master

    Before using any authentication functions, you must call Init. This sets up the authentication database (a file named authentication.json in the specified directory) and configures the token expiration duration.

    Parameters:

    • databasePath: The directory path where the authentication.json file will be stored.
    • validity: The duration in minutes for which a session token remains valid.