Skip to content

Commit

Permalink
Revert chatdownloader removal due to yt-dlp failing to download live …
Browse files Browse the repository at this point in the history
…chat properly
  • Loading branch information
CanOfSocks committed Jul 23, 2024
1 parent 1a52ca0 commit 8adb609
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN wget -q -O "/app/ytct.py" https://raw.githubusercontent.com/HoloArchivists/y
RUN apt-get purge git -y && apt-get autopurge -y

#Apply chat_downloader patch
#RUN sed -i "s/socs.value.startswith('CAA')/str(socs).startswith('CAA')/g" /usr/local/lib/python*/site-packages/chat_downloader/sites/youtube.py
RUN sed -i "s/socs.value.startswith('CAA')/str(socs).startswith('CAA')/g" /usr/local/lib/python*/site-packages/chat_downloader/sites/youtube.py
#Apply patch to yt-dlp youtube extractor to make it work with yta-raw
RUN sed -i '/if fmt.get('\'targetDurationSec\''):$/,/ continue$/s/^/#/' "$(pip show yt-dlp | grep Location | awk '{print $2}')/yt_dlp/extractor/youtube.py"

Expand Down
5 changes: 3 additions & 2 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
look_ahead = 48

# Cookies file location relative to inside the container
cookies_file = "/app/cookies.txt"
#cookies_file = "/app/cookies.txt"
cookies_file = "A:\\Users\\uncle\\Documents\\Scripts\\cookies.txt"

### Torrent options
torrent = True
Expand All @@ -91,4 +92,4 @@
communitydir = "/app/CommunityPosts"

unarchiveddir = "/app/unarchived"
unarchivedtempdir = "/app/temp/unarchived"
unarchivedtempdir = "/app/temp/unarchived"
22 changes: 11 additions & 11 deletions downloadVid.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def download_chat_ytdlp(video_url,outputFile):
with yt_dlp.YoutubeDL(options) as ydl:
ydl.download(video_url)
return 0
"""

def download_chat(id,outputFile):
if getConfig.getChat() and not getConfig.vid_Only():
try:
Expand Down Expand Up @@ -147,7 +147,7 @@ def download_chat(id,outputFile):
print("Compressing chat for {0} failed".format(id))
return 2
return 0
"""

def replace_ip_in_json(file_name):
import re
pattern = re.compile(r'((?:[0-9]{1,3}\.){3}[0-9]{1,3})|((?:[a-f0-9]{1,4}:){7}[a-f0-9]{1,4})')
Expand Down Expand Up @@ -183,12 +183,12 @@ def download_info(id,outputFile):
'live_from_start': True,
}

if getConfig.getChat():
options.update({
'writesubtitles': True,
'subtitleslangs': ['live_chat'],
'subtitlesformat': 'json',
})
#if getConfig.getChat():
# options.update({
# 'writesubtitles': True,
# 'subtitleslangs': ['livechat'],
# 'subtitlesformat': 'json',
# })

url = 'https://www.youtube.com/watch?v={0}'.format(id)
with yt_dlp.YoutubeDL(options) as ydl:
Expand Down Expand Up @@ -217,10 +217,10 @@ def downloader(id,outputTemplate, members):

# Start additional information downloaders
discord_notify = threading.Thread(target=discord_web.main, args=(id, "recording"), daemon=True)
#chat_downloader = threading.Thread(target=download_chat, args=(id,output), daemon=True)
chat_downloader = threading.Thread(target=download_chat, args=(id,output), daemon=True)
info_downloader = threading.Thread(target=download_info, args=(id,output), daemon=True)
discord_notify.start()
#chat_downloader.start()
chat_downloader.start()
info_downloader.start()


Expand All @@ -239,7 +239,7 @@ def downloader(id,outputTemplate, members):
return
# Wait for remaining processes
discord_notify.join()
#chat_downloader.join()
chat_downloader.join()
info_downloader.join()

if(getConfig.getTorrent()):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
yt-dlp>=2023.10.13
discord-webhook>=1.3.0
#chat-downloader>=0.2.8
chat-downloader>=0.2.8
psutil>=5.9.4
py3createtorrent>=1.2.0

0 comments on commit 8adb609

Please sign in to comment.