Package: fc2-live-dl
fc2-live-dlTool to download FC2 live streamsRequirementsPython 3.8ffmpegFeaturesWait for a stream to start and automatically start recordingSave comment/chat logsAuthenticate with cookies (Netscape format, same one used with youtube-dl)Remux recordings to .mp4/.m4a after it's doneContinuously monitor multiple streams in parallel and automatically start
downloading when any of them goes onlineGet notifications when streams come online viaAppriseInstallationUsing pipTo install the latest stable version:pip install --upgrade fc2-live-dlTo install the latest development version:pip install --upgrade git+https://github.com/HoloArchivists/fc2-live-dl.git#egg=fc2-live-dlUsing dockerdocker pull ghcr.io/holoarchivists/fc2-live-dl:latestUsagefc2-live-dl https://live.fc2.com/<...>usage: fc2-live-dl [-h] [-v]
                   [--quality {150Kbps,400Kbps,1.2Mbps,2Mbps,3Mbps,sound}]
                   [--latency {low,high,mid}] [--threads THREADS] [-o OUTPUT]
                   [--no-remux] [-k] [-x] [--cookies COOKIES] [--write-chat]
                   [--write-info-json] [--write-thumbnail] [--wait]
                   [--wait-for-quality-timeout WAIT_FOR_QUALITY_TIMEOUT]
                   [--poll-interval POLL_INTERVAL]
                   [--log-level {silent,error,warn,info,debug,trace}]
                   [--trust-env-proxy] [--dump-websocket]
                   url

positional arguments:
  url                   A live.fc2.com URL.

options:
  -h, --help            show this help message and exit
  -v, --version         show program's version number and exit
  --quality {150Kbps,400Kbps,1.2Mbps,2Mbps,3Mbps,sound}
                        Quality of the stream to download. Default is 3Mbps.
  --latency {low,high,mid}
                        Stream latency. Select a higher latency if
                        experiencing stability issues. Default is mid.
  --threads THREADS     The size of the thread pool used to download segments.
                        Default is 1.
  -o OUTPUT, --output OUTPUT
                        Set the output filename format. Supports formatting
                        options similar to youtube-dl. Default is '%(date)s
                        %(title)s (%(channel_name)s).%(ext)s'

                        Available format options:
                            channel_id (string): ID of the broadcast
                            channel_name (string): broadcaster's profile name
                            date (string): local date YYYY-MM-DD
                            time (string): local time HHMMSS
                            ext (string): file extension
                            title (string): title of the live broadcast
  --no-remux            Do not remux recordings into mp4/m4a after it is
                        finished.
  -k, --keep-intermediates
                        Keep the raw .ts recordings after it has been remuxed.
  -x, --extract-audio   Generate an audio-only copy of the stream.
  --cookies COOKIES     Path to a cookies file.
  --write-chat          Save live chat into a json file.
  --write-info-json     Dump output stream information into a json file.
  --write-thumbnail     Download thumbnail into a file
  --wait                Wait until the broadcast goes live, then start
                        recording.
  --wait-for-quality-timeout WAIT_FOR_QUALITY_TIMEOUT
                        If the requested quality is not available, keep
                        retrying up to this many seconds before falling back
                        to the next best quality. Default is 15 seconds.
  --poll-interval POLL_INTERVAL
                        How many seconds between checks to see if broadcast is
                        live. Default is 5.
  --log-level {silent,error,warn,info,debug,trace}
                        Log level verbosity. Default is info.
  --trust-env-proxy     Trust environment variables for proxy settings.
  --dump-websocket      Dump all websocket communication to a file for
                        debuggingUsing proxiesTo use a HTTP proxy, pass the--trust-env-proxyflag and set your proxy
settings in theHTTP_PROXY,HTTPS_PROXY,WS_PROXYorWSS_PROXYenvironment variables. If not present, proxy settings are taken from the~/.netrcfile.For more information, checkaiohttp's documentation.autofc2Monitor multiple channels at the same time, and automatically start
downloading when any of them goes onlineautofc2 --config autofc2.jsonWhere theautofc2.jsonfile looks like this:{"autofc2":{"log_level":"info"},"default_params":{"quality":"3Mbps","latency":"mid","threads":4,"outtmpl":"%(channel_name)s %(_en_name)s/%(date)s %(title)s.%(ext)s","write_chat":false,"write_info_json":false,"write_thumbnail":false,"wait_for_live":true,"wait_for_quality_timeout":15,"wait_poll_interval":5,"cookies_file":null,"remux":true,"keep_intermediates":false,"extract_audio":true,"trust_env_proxy":false},"notifications":[{"url":"discord://{WebhookID}/{WebhookToken}","message":"%(channel_name)s is live!\nhttps://live.fc2.com/%(channel_id)s"}],"channels":{"91544481":{"_en_name":"Necoma Karin","quality":"sound","write_thumbnail":true},"72364867":{"_en_name":"Uno Sakura"},"40740626":{"_en_name":"Komae Nadeshiko"},"81840800":{"_en_name":"Ronomiya Hinagiku"}}}Thedefault_paramsobject will be the parameters applied to all of the
channels. Check the usage section above for more information on each parameter.
Note thatwait_for_liveneeds to be set totruefor the script to work
properly. You can also override the parameters per-channel.Arbitrary parameters can be specified by prefixing them with_, and will be
accessible inouttmpl. This is useful for specifying custom filenames just
like in the example above. In the example I'm using_en_name, but you can use
anything as long as it starts with_.For notifications, the URL follows theApprise syntax. For
example, if you want to use Discord webhooks, use thediscord://like so:Original URL:https://discord.com/api/webhooks/12341234/abcdabcdTurns into:discord://12341234/abcdabcdYou can find out more about the different types of notifiers and how to
configure them onApprise's GitHub.Themessageof the notifications follow the same syntax asouttmpl.NOTE Windows users: When specifying a file path (e.g. for cookies) in the
json, double up your backslashes, for example:"cookies_file": "C:\\Documents\\cookies.txt".Once configured, you can run the script:autofc2 --config autofc2.jsonIf you need to change the config json, feel free to change it while the script
is running. It will reload the file if it detects any changes. Note that
parameters will not be updated for ongoing streams (i.e. if the script is
recording a stream and you change its settings, it will continue recording with
the old settings and will only apply the new configuration to future
recordings).Running autofc2 with DockerYou can run autofc2 using the Docker image by mounting your config json and your
output directory, as well as overriding the defaultcmdwithautofc2like
so:# The following mounts `./autofc2.json` into the correct location in the docker# container, as well as an `/recordings` folder for the recordings. You'll need to# set the `outtmpl` to something like `/recordings/%(channel_name)s ...`dockerrun--rm\-v$(pwd)/autofc2.json:/app/autofc2.json:ro\-v$(pwd)/recordings:/recordings\-eTZ=Asia/Tokyo\ghcr.io/holoarchivists/fc2-live-dl:latest\autofc2--config/app/autofc2.jsonThe above command runs the container in the foreground. If you want it to keep
running in the background, you can replace the--rmflag with-d. TheTZenvironment can be set to your local timezone, and will affect the timestamps in
the logs.⚠️ IMPORTANT NOTE: Make sure you set yourouttmplproperly to match the
bind mounts (-v), and test that the files are properly saved to your computer.You will lose your recordingsif you don't configure this properly!You can also use docker-compose to keep your config in a single file:Download thedocker-compose.autofc2.ymlfile into some folder, and name itdocker-compose.yml.Place yourautofc2.jsonin the same folder and modify theouttmplso it
starts with/recordings/:"outtmpl": "/recordings/%(channel_name)s %(_en_name)s/%(date)s %(title)s.%(ext)s"Run it!# Prepare the recordings directory with the right permissionsmkdir./recordings&&chown1000:1000./recordings# Run the thingdocker-composeup-d# Check the logsdocker-composelogs-f# If you wanna kill itdocker-composedownNotesFC2 does not allow multiple connections to the same stream, so you can't watch
in the browser while downloading. You can instead preview the file being
downloaded usingmpvorvlc. Alternatively, log in with an account on your
browser.Recording only starts from when you start the tool. This tool cannot "seek
back" and record streams from the start.If you can't runfc2-live-dlorautofc2, try uninstalling and reinstalling
withpip uninstall fc2-live-dl.Known issuesTested to work under Linux. It should work on Windows, but no guarantees. If
you're facing any issues on Windows, pleasefile an issue.autofc2 will freak out over a private/paid streams.--waitdoesn't work sometimes because FC2 would announce that the stream is
live before the playlist is available. Useautofc2if you want to make sure
streams get saved.When monitoring many channels withautofc2, if you face any 5xx errors, try
increasing thewait_poll_intervalto something higher.