View Single Post
  #61  
Old 04-25-2017, 09:11 PM
Damianonymous Damianonymous is offline
Senior Member
 
Join Date: Jan 2017
Posts: 187
Damianonymous is on a distinguished road
Default

Re: Chaturbate Sample Rtmpdump


Quote:
Originally Posted by ramtico View Post
And for Cam4?
The Streamlink team is working on the Cam4 plugin, I think it should be ready in version 0.6.0

If you do not want to wait, copy the following code to the notepad and save it as a Cam4.py in the ...\streamlink\plugins folder.


Code:
import re

from streamlink.plugin import Plugin
from streamlink.plugin.api import http, useragents, validate
from streamlink.stream import HLSStream, RTMPStream
from streamlink.utils import parse_json


class Cam4(Plugin):
    _url_re = re.compile(r'https?://([a-z]+\.)?cam4.com/.+')
    _video_data_re = re.compile(r"flashData: (?P<flash_data>{.*}), hlsUrl: '(?P<hls_url>.+?)'")

    _flash_data_schema = validate.Schema(
        validate.all(
            validate.transform(parse_json),
            validate.Schema({
                'playerUrl': validate.url(),
                'flashVars': validate.Schema({
                    'videoPlayUrl': validate.text,
                    'videoAppUrl': validate.url(scheme='rtmp')
                })
            })
        )
    )

    @classmethod
    def can_handle_url(cls, url):
        return Cam4._url_re.match(url)

    def _get_streams(self):
        res = http.get(self.url, headers={'User-Agent': useragents.ANDROID})
        match = self._video_data_re.search(res.text)
        if match is None:
            return

        hls_streams = HLSStream.parse_variant_playlist(
            self.session,
            match.group('hls_url'),
            headers={'Referer': self.url}
        )
        for s in hls_streams.items():
            yield s

        rtmp_video = self._flash_data_schema.validate(match.group('flash_data'))
        rtmp_stream = RTMPStream(self.session, {
            'rtmp': rtmp_video['flashVars']['videoAppUrl'],
            'playpath': rtmp_video['flashVars']['videoPlayUrl'],
            'swfUrl': rtmp_video['playerUrl']
        })
        yield 'live', rtmp_stream


__plugin__ = Cam4
Then copy the .bat script and put it in the folder together with rtmpdump.exe with the KSW patch, or replace the old rtmpdump.exe with that version in the environment path https://github.com/K-S-V/Scripts/releases

Code:
@echo off
setlocal enableDelayedExpansion

set USERNAME=AnonymousUser
set PASSWORD=anonymous

set SECONDS=15

set /p model=Enter username: 
set model=%model:https://cam4.com/=%
set model=%model:/=%

set OUT_DIR=Cam4\%model%

if not exist %OUT_DIR% (mkdir %OUT_DIR%)

for /L %%i in (1,1,99) do (
  set N=!time:~9,12!
  set /a N=10000!N! %% 10000
  set rand=!random!
  set /a rand=!rand!* 31/32768+1
  set /a rand=!N!+!rand!
  set /a rand=!rand!*31/131+1
)
set server=edge%rand%

:doCapture
for /r %%F in (*) do if %%~zF==0 @del "%%F"
set ts=%date:/=-%_%time::=-%
set ts=%ts: =%
set output=%OUT_DIR%\%model%_%ts%.flv
set PASSWORD=%PASSWORD:\u003D==%

color 2F && title %model% @ %time% - %server%
cls && echo Capturing: %model% @ %time% - %server% && echo.

streamlink "https://cam4.com/%model%/" best --http-header "swfUrl=https://static.cam4.com/client/Cam4Chatless_1.176_guest.swf" --http-header "flashVer=WIN 25.0.0.148" -o "%OUT_DIR%\%model%_%ts%.flv

for %%r in (%output%) do (
  if %%~zr lss 1 del %output%
  color 4F && title %model% - OFFLINE
)

set /a rand=%random%*31/32768+1
set server=edge%rand%

timeout %SECONDS%
goto doCapture
Reply With Quote