forked from buraktokman/FFMPEG-Stream-Recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ffmpeg_stream_mp4.py
64 lines (53 loc) · 1.61 KB
/
ffmpeg_stream_mp4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python
from urllib.parse import urlparse
from urllib.request import urlopen
from os.path import expanduser
import os, sys, re, pyperclip, datetime
new = pyperclip.paste()
parsed_url = urlparse(new)
desktop = expanduser("~") + '/Desktop'
if len(sys.argv) < 2:
if bool(parsed_url.scheme):
print('Clipboard URL is valid.')
url = new
else:
print('Stream URL need to be provided as parameter.')
exit(0)
elif len(sys.argv) < 3:
url = sys.argv[1]
def chatturbate_find_playlist(url):
# connect to a URL
website = urlopen(url)
# read html code
html = website.read()
html = str(html)
items = re.findall('https://edge(.*?)/playlist.m3u8',html,re.DOTALL)
if '[]' in str(items):
return False
else:
item = 'https://edge' + items[0] + '/playlist.m3u8'
return item
def xhamster_find_playlist(url):
pass
def myfreecams_find_playlist(url):
pass
def stream(url):
print('ffmpeg stream mp4')
now = datetime.datetime.now()
#format_string = '/Users/hummingbird/Desktop/moon/scripts/ffmpeg/ffmpeg_stream_mp4.sh ' + str(url)
format_string = 'ffmpeg -i ' + url + ' -c copy -bsf:a aac_adtstoasc ' + desktop + '/' + str(now.hour) + str(now.minute) + str(now.second) + '.mp4'
command = str(format_string)
os.system(command)
return
if __name__ == '__main__':
if 'chaturbate.com/' in url:
m3u8 = chatturbate_find_playlist(url)
elif 'xhamster.com' in url:
m3u8 = xhamster_find_playlist(url)
elif 'myfreecams.com' in url:
m3u8 = myfreecams_find_playlist(url)
if m3u8 is not False:
print(m3u8)
stream(m3u8)
else:
print('playlist.m3u8 not found')