Skip to content

Commit

Permalink
closed #477, closed #482, fixed #484, fixed #508, fixes #513; bug fix…
Browse files Browse the repository at this point in the history
…es and overall improvements
  • Loading branch information
MShawon committed Feb 7, 2023
1 parent ca16545 commit 8af6e9d
Show file tree
Hide file tree
Showing 18 changed files with 96 additions and 52 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Simple program to increase YouTube views written in Python. Works with live stre


# Requirements
* **Python 3.7.x-3.9.x**
* **Python 3.7.x-3.11.x**
* High speed Internet Connection
* Good proxy list (http, https, socks4, socks5)
* Google Chrome installed on your OS (not Chromium)
Expand Down Expand Up @@ -105,7 +105,7 @@ Simple program to increase YouTube views written in Python. Works with live stre
* [Windows from source code](https://github.com/MShawon/YouTube-Viewer#installation)
* [Linux / Mac from source code](https://github.com/MShawon/YouTube-Viewer#linux--mac)
2) Then put your video links in the [urls.txt](https://github.com/MShawon/YouTube-Viewer#urls) file
3) To search your video on YouTube and then play it put the search keywords and video title in the [search.txt](https://github.com/MShawon/YouTube-Viewer#search) file
3) To search for your video on YouTube and then play it, put the search keywords and video title in the [search.txt](https://github.com/MShawon/YouTube-Viewer#search) file
4) Get your [proxy](https://github.com/MShawon/YouTube-Viewer#proxies) list
5) Run the script and follow the instructions from there.

Expand Down Expand Up @@ -146,9 +146,9 @@ Simple program to increase YouTube views written in Python. Works with live stre
2) If you have any external link which will redirect to your youtube video you can use that too. Example : when you post a YouTube video link in **twitter** and you hit play on twitter, you will get a link like this `https://t.co/xxxxxxxxxx?amp=1`. This is helpful because YouTube will see that views are coming from External Source like twitter in this example.

# Search
Program can search youtube with the keyword you want and find video with video title. To do this you need to know what keyword can find your video on youtube search engine. Also you need to provide **exact** video title. Put keyword and title like this format `keyword :::: video title` in **search.txt**. You can use same `video title` for multiple `keyword` too.
Program can search youtube with the keyword you want and find the video with video title or video id. To do this you need to know what keyword can find your video on youtube search engine. Also you need to provide **exact** video title or video id. Put keyword and title like this format `keyword :::: video title` or `keyword :::: video id` in **search.txt**. Always use multiple `keyword` for the same `video title` or `video id`.

*If you don't know any keyword just put your `video title :::: video title` in search.txt*
*If you don't know any keyword just put your `video title :::: video title` or `video title :::: video id` in search.txt*


# Live Stream
Expand All @@ -171,7 +171,7 @@ Simple program to increase YouTube views written in Python. Works with live stre

* ## Installation

First, make sure you have installed git and Python version between 3.7.x to 3.9.x
First, make sure you have installed git and Python version between 3.7.x to 3.11.x

Open command prompt and type
```
Expand Down Expand Up @@ -210,7 +210,7 @@ Simple program to increase YouTube views written in Python. Works with live stre
# Linux / Mac
* ## Installation
First, make sure you have installed git and Python version between 3.7.x to 3.9.x
First, make sure you have installed git and Python version between 3.7.x to 3.11.x
Open your favourite terminal and run
```
Expand Down Expand Up @@ -252,7 +252,8 @@ Simple program to increase YouTube views written in Python. Works with live stre
To get the most out of this script you should maintain these things.
* Don't use HEADLESS mode. Because no IP leak prevention, fingerprint defending, etc. can be done in headless mode.
* Youtube doesn't count views from the same IP after a certain time. Like, don't expect to get 100 views from 10 proxies. If you want more views, try to use a lot of premium proxies(free proxies are flagged by most websites). DO NOT use TOR proxies.
* It seems Rotating proxy gives the best result. But the IP MUST NOT change on each request. Set the sticky session or TTL to 5 to 15 minutes.
* In a nutshell, you need Rotating proxies to get the best result. But the IP MUST NOT change on each request. Set the sticky session or TTL to 5 to 15 minutes.
* For IPRoyal it would be *Royal Residential Proxies*, not Static Residential proxies
* Use both [urls.txt](https://github.com/MShawon/YouTube-Viewer#urls) and [search.txt](https://github.com/MShawon/YouTube-Viewer#search)
* And use as many [urls](https://github.com/MShawon/YouTube-Viewer#urls) and [keyword::::title](https://github.com/MShawon/YouTube-Viewer#search) as you can. Don't use just one video.
Expand Down
Binary file removed extension/spoof_timezone.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion proxy_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file modified requirements.txt
Binary file not shown.
2 changes: 2 additions & 0 deletions search.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
keyword 1 :::: exact video title 1
keyword 2 :::: exact video title 2
keyword 3 :::: exact video title 2
keyword 1 :::: video_id 1
keyword 2 :::: video_id 2
keyword 4 :::: exact video title 3
89 changes: 63 additions & 26 deletions youtube_viewer.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -31,6 +31,7 @@

import psutil
from fake_headers import Headers, browsers
from faker import Faker
from requests.exceptions import RequestException
from tabulate import tabulate
from undetected_chromedriver.patcher import Patcher
Expand All @@ -46,7 +47,7 @@
log = logging.getLogger('werkzeug')
log.disabled = True

SCRIPT_VERSION = '1.7.6'
SCRIPT_VERSION = '1.8.0'

print(bcolors.OKGREEN + """
Expand Down Expand Up @@ -96,6 +97,7 @@
threads = 0
views = 100

fake = Faker()
cwd = os.getcwd()
patched_drivers = os.path.join(cwd, 'patched_drivers')
config_path = os.path.join(cwd, 'config.json')
Expand Down Expand Up @@ -148,10 +150,10 @@ def clean_exe_temp(folder):
if hasattr(sys, '_MEIPASS'):
temp_name = sys._MEIPASS.split('\\')[-1]
else:
if sys.version_info.minor < 7 or sys.version_info.minor > 9:
if sys.version_info.minor < 7 or sys.version_info.minor > 11:
print(
f'Your current python version is not compatible : {sys.version}')
print(f'Install Python version between 3.7.x to 3.9.x to run this script')
print(f'Install Python version between 3.7.x to 3.11.x to run this script')
input("")
sys.exit()

Expand All @@ -171,23 +173,27 @@ def update_chrome_version():

def check_update():
api_url = 'https://api.github.com/repos/MShawon/YouTube-Viewer/releases/latest'
response = requests.get(api_url, timeout=30)
try:
response = requests.get(api_url, timeout=30)

RELEASE_VERSION = response.json()['tag_name']
RELEASE_VERSION = response.json()['tag_name']

if RELEASE_VERSION > SCRIPT_VERSION:
print(bcolors.OKCYAN + '#'*100 + bcolors.ENDC)
print(bcolors.OKCYAN + 'Update Available!!! ' +
f'YouTube Viewer version {SCRIPT_VERSION} needs to update to {RELEASE_VERSION} version.' + bcolors.ENDC)
if RELEASE_VERSION > SCRIPT_VERSION:
print(bcolors.OKCYAN + '#'*100 + bcolors.ENDC)
print(bcolors.OKCYAN + 'Update Available!!! ' +
f'YouTube Viewer version {SCRIPT_VERSION} needs to update to {RELEASE_VERSION} version.' + bcolors.ENDC)

try:
notes = response.json()['body'].split('SHA256')[0].split('\r\n')
for note in notes:
if note:
print(bcolors.HEADER + note + bcolors.ENDC)
except Exception:
pass
print(bcolors.OKCYAN + '#'*100 + '\n' + bcolors.ENDC)
try:
notes = response.json()['body'].split(
'SHA256')[0].split('\r\n')
for note in notes:
if note:
print(bcolors.HEADER + note + bcolors.ENDC)
except Exception:
pass
print(bcolors.OKCYAN + '#'*100 + '\n' + bcolors.ENDC)
except Exception:
pass


def create_html(text_dict):
Expand Down Expand Up @@ -358,7 +364,7 @@ def youtube_music(driver):
return view_stat, output


def spoof_geolocation(proxy_type, proxy, driver):
def spoof_timezone_geolocation(proxy_type, proxy, driver):
try:
proxy_dict = {
"http": f"{proxy_type}://{proxy}",
Expand All @@ -369,17 +375,37 @@ def spoof_geolocation(proxy_type, proxy, driver):

if resp.status_code == 200:
location = resp.json()
params = {
tz_params = {'timezoneId': location['timezone']}
latlng_params = {
"latitude": location['lat'],
"longitude": location['lon'],
"accuracy": randint(20, 100)
}
driver.execute_cdp_cmd(
"Emulation.setGeolocationOverride", params)
info = f"ip-api.com | Lat : {location['lat']} | Lon : {location['lon']} | TZ: {location['timezone']}"
else:
raise RequestException

except RequestException:
location = fake.location_on_land()
tz_params = {'timezoneId': location[-1]}
latlng_params = {
"latitude": location[0],
"longitude": location[1],
"accuracy": randint(20, 100)
}
info = f"Random | Lat : {location[0]} | Lon : {location[1]} | TZ: {location[-1]}"

except (RequestException, WebDriverException):
try:
driver.execute_cdp_cmd('Emulation.setTimezoneOverride', tz_params)

driver.execute_cdp_cmd(
"Emulation.setGeolocationOverride", latlng_params)

except WebDriverException:
pass

return info


def control_player(driver, output, position, proxy, youtube, collect_id=True):
current_url = driver.current_url
Expand All @@ -402,6 +428,9 @@ def control_player(driver, output, position, proxy, youtube, collect_id=True):
video_len = video_len*uniform(minimum, maximum)
duration = strftime("%Hh:%Mm:%Ss", gmtime(video_len)).lstrip("0h:0m:")

if len(output) == 11:
output = driver.title[:-10]

summary[position] = [position, output, f'{duration} / {actual_duration}']
website.summary_table = tabulate(
summary.values(), headers=headers_1, numalign='center', stralign='center', tablefmt="html")
Expand Down Expand Up @@ -683,7 +712,15 @@ def main_viewer(proxy_type, proxy, position):

sleep(2)

spoof_geolocation(proxy_type, proxy, driver)
info = spoof_timezone_geolocation(proxy_type, proxy, driver)

isdetected = driver.execute_script('return navigator.webdriver')

print(timestamp() + bcolors.OKBLUE + f"Worker {position} | " + bcolors.OKGREEN +
f"{proxy} | {proxy_type.upper()} | " + bcolors.OKCYAN + f"{info} | Detected? : {isdetected}" + bcolors.ENDC)

create_html({"#3b8eea": f"Worker {position} | ",
"#23d18b": f"{proxy.split('@')[-1]} | {proxy_type.upper()} | ", "#29b2d3": f"{info} | Detected? : {isdetected}"})

if width == 0:
width = driver.execute_script('return screen.width')
Expand Down Expand Up @@ -981,11 +1018,11 @@ def main():
print(json.dumps(config, indent=4))
print(bcolors.OKCYAN + 'Config file exists! Program will start automatically after 20 seconds...' + bcolors.ENDC)
print(bcolors.FAIL + 'If you want to create a new config file PRESS CTRL+C within 20 seconds!' + bcolors.ENDC)
start = time()
start = time() + 20
try:
i = 0
while i < 96:
print(bcolors.OKBLUE + f"{time() - start:.0f} seconds remaining " +
print(bcolors.OKBLUE + f"{start - time():.0f} seconds remaining " +
animation[i % len(animation)] + bcolors.ENDC, end="\r")
i += 1
sleep(0.2)
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
16 changes: 10 additions & 6 deletions youtubeviewer/basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
WEBRTC = os.path.join('extension', 'webrtc_control.zip')
ACTIVE = os.path.join('extension', 'always_active.zip')
FINGERPRINT = os.path.join('extension', 'fingerprint_defender.zip')
TIMEZONE = os.path.join('extension', 'spoof_timezone.zip')
CUSTOM_EXTENSIONS = glob(os.path.join('extension', 'custom_extension', '*.zip')) + \
glob(os.path.join('extension', 'custom_extension', '*.crx'))

Expand Down Expand Up @@ -122,7 +121,6 @@ def get_driver(background, viewports, agent, auth_required, path, proxy, proxy_t
if not background:
options.add_extension(WEBRTC)
options.add_extension(FINGERPRINT)
options.add_extension(TIMEZONE)
options.add_extension(ACTIVE)

if CUSTOM_EXTENSIONS:
Expand Down Expand Up @@ -210,8 +208,14 @@ def scroll_search(driver, video_title):
if driver.find_element(By.XPATH, f'//ytd-item-section-renderer[{i}]').text == 'No more results':
msg = 'failed'
break
find_video = section.find_element(
By.XPATH, f'//*[@title="{video_title}"]')

if len(video_title) == 11:
find_video = section.find_element(
By.XPATH, f'//a[@id="video-title" and contains(@href, "{video_title}")]')
else:
find_video = section.find_element(
By.XPATH, f'//*[@title="{video_title}"]')

driver.execute_script(
"arguments[0].scrollIntoViewIfNeeded();", find_video)
sleep(1)
Expand Down Expand Up @@ -239,14 +243,14 @@ def search_video(driver, keyword, video_title):
type_keyword(driver, keyword, retry=True)
except WebDriverException:
raise Exception(
"Slow internet speed or Stuck at recaptcha! Can't perfrom search keyword")
"Slow internet speed or Stuck at recaptcha! Can't perform search keyword")

msg = scroll_search(driver, video_title)

if msg == 'failed':
bypass_popup(driver)

filters = driver.find_element(By.CSS_SELECTOR, '#filter-menu a')
filters = driver.find_element(By.CSS_SELECTOR, '#filter-menu button')
driver.execute_script('arguments[0].scrollIntoViewIfNeeded()', filters)
sleep(randint(1, 3))
ensure_click(driver, filters)
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/bypass.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/colors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/database.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/download_driver.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions youtubeviewer/features.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -216,7 +216,7 @@ def play_from_channel(driver, actual_channel):

driver.refresh()
videos = WebDriverWait(driver, 10).until(
EC.presence_of_all_elements_located((By.XPATH, "//a[@id='video-title']")))
EC.presence_of_all_elements_located((By.XPATH, "//a[@id='video-title-link']")))
video = choice(videos)
driver.execute_script("arguments[0].scrollIntoViewIfNeeded();", video)
sleep(randint(2, 5))
Expand Down
2 changes: 1 addition & 1 deletion youtubeviewer/load_files.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
MIT License
Copyright (c) 2021-2022 MShawon
Copyright (c) 2021-2023 MShawon
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

1 comment on commit 8af6e9d

@he0xRuby
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an error in the code on line 39

Please sign in to comment.