Skip to content

Commit

Permalink
added /cmd/ example, removed --file support
Browse files Browse the repository at this point in the history
  • Loading branch information
back-to committed Jun 17, 2022
1 parent 2ccd08b commit 1f8d857
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 255 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Added

- YT-DLP can now also be used.
- new URL with `/cmd/commands without encoding`

### Changed

Expand All @@ -15,6 +16,7 @@
- Python 3.6 support
- URL with `/play/` `/streamlink/` `/301/` `/streamlink_301/`
such as `http://127.0.0.1:53422/play/?url=https://foo.bar&q=worst`
- commands to create files for Base64, use direct URLs with /cmd/ instead

## 2.0.0

Expand Down
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
include CHANGELOG.md
include README.md

recursive-include tests *py

prune */__pycache__
global-exclude *.pyc *~ *.bak *.swp *.pyo
79 changes: 21 additions & 58 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,6 @@ sudo -H python3 -m pip install --upgrade liveproxy
sudo -H python3 -m pip install --upgrade git+https://github.com/back-to/liveproxy.git
```

## source

```text
git clone https://github.com/back-to/liveproxy.git
cd liveproxy
python3 setup.py install
```

# URL-GUIDE

## Tutorial
Expand All @@ -59,92 +51,63 @@ Now that LiveProxy is running, you will have to create a valid URL.

For the examples here, ``53422`` is used as **default port**.

## Base64

You will need to base64 encode your used commands.
## CMD

#### Streamlink
If needed, you can use `quote` for special characters
https://docs.python.org/3/library/urllib.parse.html#urllib.parse.quote

```text
http://127.0.0.1:53422/base64/STREAMLINK-COMMANDS/
http://127.0.0.1:53422/cmd/COMMANDS/
```

Example for `streamlink https://www.youtube.com/user/france24/live best`

```text
http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmUgYmVzdA==/
http://127.0.0.1:53422/cmd/streamlink https://www.youtube.com/user/france24/live best/
```

#### Youtube-DL
Example for `yt-dlp https://www.youtube.com/user/france24/live`

```text
http://127.0.0.1:53422/base64/YOUTUBE-DL-COMMANDS/
http://127.0.0.1:53422/cmd/yt-dlp https://www.youtube.com/user/france24/live/
```

Example for `youtube-dl https://www.youtube.com/user/france24/live`
## Base64

```text
http://127.0.0.1:53422/base64/eW91dHViZS1kbCBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmU=/
```
You will need to base64 encode your used commands.

#### YT-DLP
#### Streamlink

```text
http://127.0.0.1:53422/base64/YT-DLP-COMMANDS/
http://127.0.0.1:53422/base64/STREAMLINK-COMMANDS/
```

Example for `yt-dlp https://www.youtube.com/user/france24/live`
Example for `streamlink https://www.youtube.com/user/france24/live best`

```text
http://127.0.0.1:53422/base64/eXQtZGxwIGh0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3VzZXIvZnJhbmNlMjQvbGl2ZQ==/
http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmUgYmVzdA==/
```

### LiveProxy-Command

LiveProxy can create this URL automatically.

Create a new file with your commands.
#### Youtube-DL

```text
#EXTM3U
#EXTINF:-1,Arte FR
streamlink https://www.arte.tv/fr/direct/ 720p,720p_alt,best
#EXTINF:-1,France24
streamlink https://www.youtube.com/user/france24/live best
#EXTINF:-1 tvg-id="EuroNews" tvg-name="EuroNews",Euronews
streamlink https://www.euronews.com/live best
#EXTINF:-1,France24 YOUTUBE-DL
youtube-dl https://www.youtube.com/user/france24/live
#EXTINF:-1,France24 YT-DLP
yt-dlp https://www.youtube.com/user/france24/live
http://127.0.0.1:53422/base64/YOUTUBE-DL-COMMANDS/
```

For this example the filename is `example.m3u`
Example for `youtube-dl https://www.youtube.com/user/france24/live`

```text
liveproxy --file example.m3u
http://127.0.0.1:53422/base64/eW91dHViZS1kbCBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmU=/
```

It will create a new file `example.m3u.new` with valid URLs,
only lines with `streamlink`, `youtube-dl`, `youtube_dl`, `yt-dlp` or `yt_dlp` at the start will be changed.
#### YT-DLP

```text
#EXTM3U
#EXTINF:-1,Arte FR
http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy5hcnRlLnR2L2ZyL2RpcmVjdC8gNzIwcCw3MjBwX2FsdCxiZXN0/
#EXTINF:-1,France24
http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmUgYmVzdA==/
#EXTINF:-1 tvg-id="EuroNews" tvg-name="EuroNews",Euronews
http://127.0.0.1:53422/base64/c3RyZWFtbGluayBodHRwczovL3d3dy5ldXJvbmV3cy5jb20vbGl2ZSBiZXN0/
#EXTINF:-1,France24 YOUTUBE-DL
http://127.0.0.1:53422/base64/eW91dHViZS1kbCBodHRwczovL3d3dy55b3V0dWJlLmNvbS91c2VyL2ZyYW5jZTI0L2xpdmU=/
#EXTINF:-1,France24 YT-DLP
http://127.0.0.1:53422/base64/eXQtZGxwIGh0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3VzZXIvZnJhbmNlMjQvbGl2ZQ==/
http://127.0.0.1:53422/base64/YT-DLP-COMMANDS/
```

You can also use ``--file-output`` for a specified new file,
but be careful don't overwrite any important files.
Example for `yt-dlp https://www.youtube.com/user/france24/live`

```text
liveproxy --file example.m3u --file-output my_file.m3u
http://127.0.0.1:53422/base64/eXQtZGxwIGh0dHBzOi8vd3d3LnlvdXR1YmUuY29tL3VzZXIvZnJhbmNlMjQvbGl2ZQ==/
```
2 changes: 1 addition & 1 deletion liveproxy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '2.1.0.dev3'
__version__ = "2.1.0.dev4"
123 changes: 36 additions & 87 deletions liveproxy/argparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,19 @@

from liveproxy import __version__ as liveproxy_version

FILE_OUTPUT_LIST = ['.m3u', '.m3u8', '.new', '.txt']


def file_output_list(value):
if not value.endswith(tuple(FILE_OUTPUT_LIST)):
raise ValueError

return value


def num(type, min=None, max=None):
def func(value):
value = type(value)
if min is not None and not (value > min):
raise argparse.ArgumentTypeError(
'{0} value must be more than {1} but is {2}'.format(
"{0} value must be more than {1} but is {2}".format(
type.__name__, min, value
)
)
if max is not None and not (value <= max):
raise argparse.ArgumentTypeError(
'{0} value must be at most {1} but is {2}'.format(
"{0} value must be at most {1} but is {2}".format(
type.__name__, max, value
)
)
Expand All @@ -35,112 +26,70 @@ def func(value):


parser = argparse.ArgumentParser(
fromfile_prefix_chars='@',
fromfile_prefix_chars="@",
add_help=False,
usage='%(prog)s --host [HOST] --port [PORT]',
description=dedent('''
usage="%(prog)s --host [HOST] --port [PORT]",
description=dedent("""
LiveProxy is a local URL Proxy for Streamlink
'''),
epilog=dedent('''
"""),
epilog=dedent("""
For more in-depth documentation see:
https://liveproxy.github.io/
''')
https://github.com/back-to/liveproxy/blob/master/README.md
""")
)

general = parser.add_argument_group('General options')
general = parser.add_argument_group("General options")
general.add_argument(
'-h', '--help',
action='store_true',
help='''
"-h", "--help",
action="store_true",
help="""
Show this help message and exit.
'''
"""
)
general.add_argument(
'-V', '--version',
action='version',
version='%(prog)s {0}'.format(liveproxy_version),
help='''
"-V", "--version",
action="version",
version="%(prog)s {0}".format(liveproxy_version),
help="""
Show version number and exit.
'''
"""
)
general.add_argument(
'--loglevel',
metavar='LEVEL',
choices=('CRITICAL', 'ERROR', 'WARNING', 'INFO', 'DEBUG', 'NOTSET'),
default='INFO',
help='''
"--loglevel",
metavar="LEVEL",
choices=("CRITICAL", "ERROR", "WARNING", "INFO", "DEBUG", "NOTSET"),
default="INFO",
help="""
Set the log message threshold.
https://docs.python.org/3/library/logging.html#logging-levels
Valid levels are: CRITICAL, ERROR, WARNING, INFO, DEBUG, NOTSET
'''
"""
)

server = parser.add_argument_group('Server options')
server = parser.add_argument_group("Server options")
server.add_argument(
'--host',
metavar='HOST',
"--host",
metavar="HOST",
type=str,
default='127.0.0.1',
help='''
default="127.0.0.1",
help="""
A fixed IP to use as a HOST.
Can also be used for `--file`
Default is 127.0.0.1
'''
"""
)
server.add_argument(
'--port',
metavar='PORT',
"--port",
metavar="PORT",
type=num(int, min=0, max=65535),
default=53422,
help='''
help="""
A fixed PORT to use for the HOST.
Can also be used for `--file`
Default is 53422
'''
)

url = parser.add_argument_group('URL options')
url.add_argument(
'--file',
metavar='FILE',
help='''
Read the given file and create a new file with base64
encoded URLs for LiveProxy.
It will only encode lines that starts with `streamlink`,
other lines will be ignored.
You can use `--file-output` to specify the new file.
'''
)
url.add_argument(
'--file-output',
metavar='FILE',
type=file_output_list,
help='''
Use a custom output file for `--file` instead of a '.new' file.
Valid files are: {0}
'''.format(' '.join(FILE_OUTPUT_LIST))
)
url.add_argument(
'--format',
default='m3u',
choices=['m3u', 'e2'],
help='''
Some playlists need special settings:
For E2 Linux Receivers with Userbouquets,
use `--format e2`
Default is m3u
''',
"""
)

__all__ = ['parser']
__all__ = ["parser"]
64 changes: 0 additions & 64 deletions liveproxy/files.py

This file was deleted.

Loading

0 comments on commit 1f8d857

Please sign in to comment.