Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
S
SHMCamStudio
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SexHackMe
SHMCamStudio
Commits
3b722898
Commit
3b722898
authored
Jun 24, 2025
by
nextime
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add qbrowser test
parent
ee7ebecd
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1003 additions
and
405 deletions
+1003
-405
qbrowser.py
qbrowser.py
+674
-0
shmcamstudio.conf
shmcamstudio.conf
+3
-0
browser.py
shmcs/browser.py
+108
-38
test.py
test.py
+218
-367
No files found.
qbrowser.py
0 → 100755
View file @
3b722898
This diff is collapsed.
Click to expand it.
shmcamstudio.conf
View file @
3b722898
...
@@ -7,6 +7,9 @@ stream_url = https://192.168.42.1/HLS/record/Live.m3u8
...
@@ -7,6 +7,9 @@ stream_url = https://192.168.42.1/HLS/record/Live.m3u8
rtmp_url
=
rtmp
://
192
.
168
.
42
.
1
/
record
/
Live
rtmp_url
=
rtmp
://
192
.
168
.
42
.
1
/
record
/
Live
port
=
5000
port
=
5000
[
Browser
]
auto_launch
=
true
[
Tkinter
]
[
Tkinter
]
window_title
=
SHM
Cam
Studio
window_title
=
SHM
Cam
Studio
button_width
=
20
button_width
=
20
...
...
shmcs/browser.py
View file @
3b722898
...
@@ -6,49 +6,111 @@ import os
...
@@ -6,49 +6,111 @@ import os
from
datetime
import
datetime
from
datetime
import
datetime
from
pathlib
import
Path
from
pathlib
import
Path
import
logging
import
logging
from
typing
import
List
,
Optional
import
uuid
from
playwright_helper
import
BASE_PROFILE_DIR
,
BASE_STATE_DIR
,
PersistentBrowser
logging
.
getLogger
(
__name__
)
logging
.
getLogger
(
__name__
)
async
def
new_context
(
url
,
persistent_browser
:
PersistentBrowser
,
context_id
:
str
,
extension_paths
:
List
[
Path
],
**
kwargs
):
logging
.
info
(
kwargs
)
# Create a new context with the pre-set extensions
context
=
await
persistent_browser
.
new_context
(
context_id
=
context_id
,
extension_paths
=
extension_paths
,
**
kwargs
)
# Open a new page in the context
page
=
await
context
.
new_page
()
# Navigate to a sample website
await
page
.
goto
(
url
)
# Print the page title as an example action
logging
.
info
(
f
"Page title for context {context_id}: {await page.title()}"
)
return
context
async
def
monitor_stream
(
log_path
,
domain
):
async
def
monitor_stream
(
log_path
,
domain
):
async
with
async_playwright
()
as
p
:
async
with
async_playwright
()
as
p
:
browser_is_pw
=
False
browser_is_pw
=
False
try
:
#try:
browser
=
await
p
.
chromium
.
connect_over_cdp
(
"http://localhost:9222"
)
# browser = await p.chromium.connect_over_cdp("http://localhost:9222")
except
:
#except:
user_data_dir
=
'./user-data'
# user_data_dir = './user-data'
cont
=
await
p
.
chromium
.
launch_persistent_context
(
user_data_dir
,
# cont = await p.chromium.launch_persistent_context(user_data_dir,
#viewport=None,
# #viewport=None,
headless
=
False
,
# headless=False,
args
=
[
# args=[
"--disable-infobars"
,
# "--disable-infobars",
#"--disable-features=Antaniu"
# #"--disable-features=Antaniu"
# ],
# ignore_default_args=["--enable-automation", "--no-sandbox"],)
# pages = cont.pages
# browser_is_pw = True
## if pages:
# page = pages[0]
# else:
# page = await cont.new_page()
# logger.info(page.url)
# await page.goto('http://localhost:5000/chat')
# logger.info("Browser session retained")
# #await browser.close()
# browser = cont.browser
# Ensure base directories exist
BASE_PROFILE_DIR
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
BASE_STATE_DIR
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
use_persistent_context
=
False
# Define pre-set extensions to be copied to all contexts
EXTENSION_PATHS
=
[
Path
(
"./my_extension1"
),
# Example: use forward slashes for cross-platform compatibility
Path
(
"./my_extension2"
)
# Replace with actual paths to unpacked extension directories
]
# Create simulated browser with the chosen mode and extensions
browser
=
PersistentBrowser
(
p
,
BASE_PROFILE_DIR
,
use_persistent_context
,
EXTENSION_PATHS
,
args
=
[
"--disable-infobars"
,
"--disable-features=Antaniu"
],
],
ignore_default_args
=
[
"--enable-automation"
,
"--no-sandbox"
],)
ignore_default_args
=
[
"--enable-automation"
,
"--no-sandbox"
])
pages
=
cont
.
pages
await
browser
.
launch
()
browser_is_pw
=
True
if
pages
:
# Create tasks for multiple contexts
page
=
pages
[
0
]
tasks
=
[]
else
:
page
=
await
cont
.
new_page
()
context_id
=
str
(
uuid
.
uuid4
())
# Unique ID for each context
logger
.
info
(
page
.
url
)
##tasks.append(new_context("http://localhost:5000/chat", browser, context_id, EXTENSION_PATHS))
await
page
.
goto
(
'http://localhost:5000/chat'
)
##await asyncio.gather(*tasks)
logger
.
info
(
"Browser session retained"
)
await
new_context
(
"http://localhost:5000/chat"
,
browser
,
context_id
,
EXTENSION_PATHS
,
viewport
=
None
)
#await browser.close()
browser
=
cont
.
browser
bw
=
0
bw
=
0
dw
=
0
dw
=
0
bh
=
0
bh
=
0
bw
=
0
bw
=
0
while
True
:
while
len
(
browser
.
contexts
())
>
0
:
browser
=
cont
.
browser
#browser = cont.browser
if
browser
:
#if browser:
contexts
=
browser
.
contexts
# contexts = browser.contexts
else
:
#else:
contexts
=
[
cont
]
# contexts = [cont]
contexts
=
browser
.
contexts
()
logging
.
info
(
"MUMBER OF CONTEXTS:
%
d"
,
len
(
browser
.
contexts
()))
for
context
in
contexts
:
for
context
in
contexts
:
logger
.
debug
(
"@@@@@@@@@@@ NEW CONTEXT @@@@@@@@"
)
logger
.
debug
(
"@@@@@@@@@@@ NEW CONTEXT @@@@@@@@"
)
if
browser_is_pw
:
if
browser_is_pw
:
sizedone
=
False
sizedone
=
False
logging
.
info
(
"NUMBER OF PAGES IN THIS CONTEXT:
%
d"
,
len
(
context
.
pages
))
for
page
in
context
.
pages
:
for
page
in
context
.
pages
:
logger
.
info
(
"newpagess----------------"
)
logger
.
info
(
"newpagess----------------"
)
if
browser_is_pw
and
not
sizedone
:
if
browser_is_pw
and
not
sizedone
:
...
@@ -76,10 +138,17 @@ async def monitor_stream(log_path, domain):
...
@@ -76,10 +138,17 @@ async def monitor_stream(log_path, domain):
# XXX THIS IS FUCKONG BLOCKING, TODO: RAKE IT OUT AND PUT THE
# XXX THIS IS FUCKONG BLOCKING, TODO: RAKE IT OUT AND PUT THE
# WHOLE THING IN A STATE MACHINE
# WHOLE THING IN A STATE MACHINE
await
monitor_requests
(
page
,
log_path
)
await
monitor_requests
(
page
,
log_path
)
if
len
(
context
.
pages
)
<
1
and
len
(
browser
.
contexts
())
==
1
:
#await context.close()
logging
.
info
(
"CLOOOOOOSSSINNNNNNGGGG"
)
await
browser
.
close
()
# XXX TODO: I ALREADY SAID MAKE A FUCKING STATE MACHINE?
# XXX TODO: I ALREADY SAID MAKE A FUCKING STATE MACHINE?
logger
.
info
(
"PORCDIOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
\b\b
"
)
#logger.info("PORCDIOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO\b\b")
await
asyncio
.
sleep
(
3
)
# Check every 0.1 seconds
await
asyncio
.
sleep
(
.1
)
# Check every 0.1 seconds
# Close the simulated browser, saving states and backing up profiles
#await browser.close()
async
def
monitor_requests
(
page
,
log_path
):
async
def
monitor_requests
(
page
,
log_path
):
async
def
log_request
(
request
):
async
def
log_request
(
request
):
...
@@ -122,12 +191,13 @@ async def monitor_requests(page, log_path):
...
@@ -122,12 +191,13 @@ async def monitor_requests(page, log_path):
def
run_browser
():
def
run_browser
():
lpath
=
str
(
Path
(
Path
.
home
(),
Path
(
'streamon.log'
)))
lpath
=
str
(
Path
(
Path
.
home
(),
Path
(
'streamon.log'
)))
#parser = argparse.ArgumentParser(description="Monitor Streamate requests")
# Check if browser should be launched automatically
#parser.add_argument("--log_path", type=str, default=lpath,
auto_launch
=
config
.
getboolean
(
'Browser'
,
'auto_launch'
,
fallback
=
False
)
# help="Path to the log file")
#parser.add_argument("--domain", type=str, default="performerclient.streamatemodels.com",
if
not
auto_launch
:
# help="URL to monitor")
logging
.
info
(
"Browser auto-launch is disabled. Set auto_launch=true in [Browser] section of shmcamstudio.conf to enable."
)
#args = parser.parse_args()
return
logging
.
info
(
"Starting browser..."
)
logging
.
info
(
"Starting browser..."
)
log_dir
=
os
.
path
.
dirname
(
lpath
)
log_dir
=
os
.
path
.
dirname
(
lpath
)
if
log_dir
and
not
os
.
path
.
exists
(
log_dir
):
if
log_dir
and
not
os
.
path
.
exists
(
log_dir
):
...
...
test.py
View file @
3b722898
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment