mirror of
https://github.com/bellingcat/auto-archiver.git
synced 2026-06-12 13:18:28 +03:00
Compare commits
33 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1382f8b795 | ||
|
|
fac8364762 | ||
|
|
0feeb0bd24 | ||
|
|
ddb9dc87d7 | ||
|
|
e8935b9a80 | ||
|
|
b157f9a6b1 | ||
|
|
ea38a604bb | ||
|
|
53494c961e | ||
|
|
f7839a99cc | ||
|
|
7a2119e6e9 | ||
|
|
3ae25e51e7 | ||
|
|
9584193d69 | ||
|
|
0dd45d90f1 | ||
|
|
edcb2da74a | ||
|
|
17d9bf694f | ||
|
|
368395ffa8 | ||
|
|
21d7d2e16c | ||
|
|
0bbb4c9b08 | ||
|
|
a30607801f | ||
|
|
c75d54a4ec | ||
|
|
804fcb1204 | ||
|
|
b2adceff25 | ||
|
|
92a0a92b47 | ||
|
|
bf3c04b3fc | ||
|
|
7eebecdb2c | ||
|
|
b17b5953dd | ||
|
|
ceb717ea65 | ||
|
|
6e4fb76940 | ||
|
|
810a31b1f0 | ||
|
|
8b15d733b1 | ||
|
|
ca37d54b7f | ||
|
|
a1742b5565 | ||
|
|
60a1f3a27a |
11
Dockerfile
11
Dockerfile
@@ -4,7 +4,6 @@ ENV RUNNING_IN_DOCKER=1
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
# TODO: use custom ffmpeg builds instead of apt-get install
|
|
||||||
RUN pip install --upgrade pip && \
|
RUN pip install --upgrade pip && \
|
||||||
pip install pipenv && \
|
pip install pipenv && \
|
||||||
add-apt-repository ppa:mozillateam/ppa && \
|
add-apt-repository ppa:mozillateam/ppa && \
|
||||||
@@ -18,18 +17,14 @@ RUN pip install --upgrade pip && \
|
|||||||
rm geckodriver-v*
|
rm geckodriver-v*
|
||||||
|
|
||||||
|
|
||||||
# TODO: avoid copying unnecessary files, including .git
|
|
||||||
COPY Pipfile* ./
|
COPY Pipfile* ./
|
||||||
RUN pipenv install
|
# install from pipenv, with browsertrix-only requirements
|
||||||
|
RUN pipenv install && \
|
||||||
|
pipenv install pywb uwsgi
|
||||||
|
|
||||||
# doing this at the end helps during development, builds are quick
|
# doing this at the end helps during development, builds are quick
|
||||||
COPY ./src/ .
|
COPY ./src/ .
|
||||||
|
|
||||||
# TODO: figure out how to make volumes not be root, does it depend on host or dockerfile?
|
|
||||||
# RUN useradd --system --groups sudo --shell /bin/bash archiver && chown -R archiver:sudo .
|
|
||||||
# USER archiver
|
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT ["pipenv", "run", "python3", "-m", "auto_archiver"]
|
ENTRYPOINT ["pipenv", "run", "python3", "-m", "auto_archiver"]
|
||||||
|
|
||||||
# should be executed with 2 volumes (3 if local_storage is used)
|
# should be executed with 2 volumes (3 if local_storage is used)
|
||||||
|
|||||||
8
Pipfile
8
Pipfile
@@ -32,15 +32,13 @@ cryptography = "*"
|
|||||||
dataclasses-json = "*"
|
dataclasses-json = "*"
|
||||||
yt-dlp = "*"
|
yt-dlp = "*"
|
||||||
vk-url-scraper = "*"
|
vk-url-scraper = "*"
|
||||||
uwsgi = "*"
|
|
||||||
requests = {extras = ["socks"], version = "*"}
|
requests = {extras = ["socks"], version = "*"}
|
||||||
# wacz = "==0.4.8"
|
|
||||||
numpy = "*"
|
numpy = "*"
|
||||||
warcio = "*"
|
warcio = "*"
|
||||||
|
|
||||||
[requires]
|
|
||||||
python_version = "3.10"
|
|
||||||
|
|
||||||
[dev-packages]
|
[dev-packages]
|
||||||
autopep8 = "*"
|
autopep8 = "*"
|
||||||
setuptools-pipfile = "*"
|
setuptools-pipfile = "*"
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.10"
|
||||||
|
|||||||
719
Pipfile.lock
generated
719
Pipfile.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -8,8 +8,8 @@ TAG=$(python -c 'from src.auto_archiver.version import __version__; print("v" +
|
|||||||
read -p "Creating new release for $TAG. Do you want to continue? [Y/n] " prompt
|
read -p "Creating new release for $TAG. Do you want to continue? [Y/n] " prompt
|
||||||
|
|
||||||
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
|
if [[ $prompt == "y" || $prompt == "Y" || $prompt == "yes" || $prompt == "Yes" ]]; then
|
||||||
git add -A
|
# git add -A
|
||||||
git commit -m "Bump version to $TAG for release" || true && git push
|
# git commit -m "Bump version to $TAG for release" || true && git push
|
||||||
echo "Creating new git tag $TAG"
|
echo "Creating new git tag $TAG"
|
||||||
git tag "$TAG" -m "$TAG"
|
git tag "$TAG" -m "$TAG"
|
||||||
git push --tags
|
git push --tags
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ class TwitterArchiver(Archiver):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
name = "twitter_archiver"
|
name = "twitter_archiver"
|
||||||
link_pattern = re.compile(r"twitter.com\/(?:\#!\/)?(\w+)\/status(?:es)?\/(\d+)")
|
link_pattern = re.compile(r"(?:twitter|x).com\/(?:\#!\/)?(\w+)\/status(?:es)?\/(\d+)")
|
||||||
link_clean_pattern = re.compile(r"(.+twitter\.com\/.+\/\d+)(\?)*.*")
|
link_clean_pattern = re.compile(r"(.+(?:twitter|x)\.com\/.+\/\d+)(\?)*.*")
|
||||||
|
|
||||||
def __init__(self, config: dict) -> None:
|
def __init__(self, config: dict) -> None:
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class YoutubeDLArchiver(Archiver):
|
|||||||
logger.debug('Using Facebook cookie')
|
logger.debug('Using Facebook cookie')
|
||||||
yt_dlp.utils.std_headers['cookie'] = self.facebook_cookie
|
yt_dlp.utils.std_headers['cookie'] = self.facebook_cookie
|
||||||
|
|
||||||
ydl = yt_dlp.YoutubeDL({'outtmpl': os.path.join(ArchivingContext.get_tmp_dir(), f'%(id)s.%(ext)s'), 'quiet': False})
|
ydl = yt_dlp.YoutubeDL({'outtmpl': os.path.join(ArchivingContext.get_tmp_dir(), f'%(id)s.%(ext)s'), 'quiet': False, 'noplaylist': True})
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# don'd download since it can be a live stream
|
# don'd download since it can be a live stream
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class Media:
|
|||||||
try:
|
try:
|
||||||
streams = ffmpeg.probe(self.filename, select_streams='v')['streams']
|
streams = ffmpeg.probe(self.filename, select_streams='v')['streams']
|
||||||
logger.warning(f"STREAMS FOR {self.filename} {streams}")
|
logger.warning(f"STREAMS FOR {self.filename} {streams}")
|
||||||
return any(s.get("duration_ts") > 0 for s in streams)
|
return any(s.get("duration_ts", 0) > 0 for s in streams)
|
||||||
except Error: return False # ffmpeg errors when reading bad files
|
except Error: return False # ffmpeg errors when reading bad files
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
|
|||||||
@@ -26,11 +26,16 @@ class PdqHashEnricher(Enricher):
|
|||||||
def enrich(self, to_enrich: Metadata) -> None:
|
def enrich(self, to_enrich: Metadata) -> None:
|
||||||
url = to_enrich.get_url()
|
url = to_enrich.get_url()
|
||||||
logger.debug(f"calculating perceptual hashes for {url=}")
|
logger.debug(f"calculating perceptual hashes for {url=}")
|
||||||
|
media_with_hashes = []
|
||||||
|
|
||||||
for m in to_enrich.media:
|
for m in to_enrich.media:
|
||||||
for media in m.all_inner_media(True):
|
for media in m.all_inner_media(True):
|
||||||
if media.is_image() and "screenshot" not in media.get("id") and "warc-file-" not in media.get("id") and len(hd := self.calculate_pdq_hash(media.filename)):
|
media_id = media.get("id", "")
|
||||||
|
if media.is_image() and "screenshot" not in media_id and "warc-file-" not in media_id and len(hd := self.calculate_pdq_hash(media.filename)):
|
||||||
media.set("pdq_hash", hd)
|
media.set("pdq_hash", hd)
|
||||||
|
media_with_hashes.append(media.filename)
|
||||||
|
|
||||||
|
logger.debug(f"calculated '{len(media_with_hashes)}' perceptual hashes for {url=}: {media_with_hashes}")
|
||||||
|
|
||||||
def calculate_pdq_hash(self, filename):
|
def calculate_pdq_hash(self, filename):
|
||||||
# returns a hexadecimal string with the perceptual hash for the given filename
|
# returns a hexadecimal string with the perceptual hash for the given filename
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class WaczArchiverEnricher(Enricher, Archiver):
|
|||||||
def configs() -> dict:
|
def configs() -> dict:
|
||||||
return {
|
return {
|
||||||
"profile": {"default": None, "help": "browsertrix-profile (for profile generation see https://github.com/webrecorder/browsertrix-crawler#creating-and-using-browser-profiles)."},
|
"profile": {"default": None, "help": "browsertrix-profile (for profile generation see https://github.com/webrecorder/browsertrix-crawler#creating-and-using-browser-profiles)."},
|
||||||
|
"docker_commands": {"default": None, "help":"if a custom docker invocation is needed"},
|
||||||
"timeout": {"default": 120, "help": "timeout for WACZ generation in seconds"},
|
"timeout": {"default": 120, "help": "timeout for WACZ generation in seconds"},
|
||||||
"extract_media": {"default": True, "help": "If enabled all the images/videos/audio present in the WACZ archive will be extracted into separate Media. The .wacz file will be kept untouched."}
|
"extract_media": {"default": True, "help": "If enabled all the images/videos/audio present in the WACZ archive will be extracted into separate Media. The .wacz file will be kept untouched."}
|
||||||
}
|
}
|
||||||
@@ -46,51 +47,45 @@ class WaczArchiverEnricher(Enricher, Archiver):
|
|||||||
url = to_enrich.get_url()
|
url = to_enrich.get_url()
|
||||||
|
|
||||||
collection = str(uuid.uuid4())[0:8]
|
collection = str(uuid.uuid4())[0:8]
|
||||||
browsertrix_home = os.path.abspath(ArchivingContext.get_tmp_dir())
|
browsertrix_home_host = os.environ.get('BROWSERTRIX_HOME_HOST') or os.path.abspath(ArchivingContext.get_tmp_dir())
|
||||||
|
browsertrix_home_container = os.environ.get('BROWSERTRIX_HOME_CONTAINER') or browsertrix_home_host
|
||||||
|
|
||||||
if os.getenv('RUNNING_IN_DOCKER'):
|
cmd = [
|
||||||
|
"crawl",
|
||||||
|
"--url", url,
|
||||||
|
"--scopeType", "page",
|
||||||
|
"--generateWACZ",
|
||||||
|
"--text",
|
||||||
|
"--screenshot", "fullPage",
|
||||||
|
"--collection", collection,
|
||||||
|
"--id", collection,
|
||||||
|
"--saveState", "never",
|
||||||
|
"--behaviors", "autoscroll,autoplay,autofetch,siteSpecific",
|
||||||
|
"--behaviorTimeout", str(self.timeout),
|
||||||
|
"--timeout", str(self.timeout)]
|
||||||
|
|
||||||
|
# call docker if explicitly enabled or we are running on the host (not in docker)
|
||||||
|
use_docker = os.environ.get('WACZ_ENABLE_DOCKER') or not os.environ.get('RUNNING_IN_DOCKER')
|
||||||
|
|
||||||
|
if use_docker:
|
||||||
|
logger.debug(f"generating WACZ in Docker for {url=}")
|
||||||
|
logger.debug(f"{browsertrix_home_host=} {browsertrix_home_container=}")
|
||||||
|
if self.docker_commands:
|
||||||
|
cmd = self.docker_commands + cmd
|
||||||
|
else:
|
||||||
|
cmd = ["docker", "run", "--rm", "-v", f"{browsertrix_home_host}:/crawls/", "webrecorder/browsertrix-crawler"] + cmd
|
||||||
|
|
||||||
|
if self.profile:
|
||||||
|
profile_fn = os.path.join(browsertrix_home_container, "profile.tar.gz")
|
||||||
|
logger.debug(f"copying {self.profile} to {profile_fn}")
|
||||||
|
shutil.copyfile(self.profile, profile_fn)
|
||||||
|
cmd.extend(["--profile", os.path.join("/crawls", "profile.tar.gz")])
|
||||||
|
|
||||||
|
else:
|
||||||
logger.debug(f"generating WACZ without Docker for {url=}")
|
logger.debug(f"generating WACZ without Docker for {url=}")
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"crawl",
|
|
||||||
"--url", url,
|
|
||||||
"--scopeType", "page",
|
|
||||||
"--generateWACZ",
|
|
||||||
"--text",
|
|
||||||
"--screenshot", "fullPage",
|
|
||||||
"--collection", collection,
|
|
||||||
"--id", collection,
|
|
||||||
"--saveState", "never",
|
|
||||||
"--behaviors", "autoscroll,autoplay,autofetch,siteSpecific",
|
|
||||||
"--behaviorTimeout", str(self.timeout),
|
|
||||||
"--timeout", str(self.timeout)]
|
|
||||||
|
|
||||||
if self.profile:
|
if self.profile:
|
||||||
cmd.extend(["--profile", os.path.join("/app", str(self.profile))])
|
cmd.extend(["--profile", os.path.join("/app", str(self.profile))])
|
||||||
else:
|
|
||||||
logger.debug(f"generating WACZ in Docker for {url=}")
|
|
||||||
|
|
||||||
cmd = [
|
|
||||||
"docker", "run",
|
|
||||||
"--rm", # delete container once it has completed running
|
|
||||||
"-v", f"{browsertrix_home}:/crawls/",
|
|
||||||
# "-it", # this leads to "the input device is not a TTY"
|
|
||||||
"webrecorder/browsertrix-crawler", "crawl",
|
|
||||||
"--url", url,
|
|
||||||
"--scopeType", "page",
|
|
||||||
"--generateWACZ",
|
|
||||||
"--text",
|
|
||||||
"--screenshot", "fullPage",
|
|
||||||
"--collection", collection,
|
|
||||||
"--behaviors", "autoscroll,autoplay,autofetch,siteSpecific",
|
|
||||||
"--behaviorTimeout", str(self.timeout),
|
|
||||||
"--timeout", str(self.timeout)
|
|
||||||
]
|
|
||||||
|
|
||||||
if self.profile:
|
|
||||||
profile_fn = os.path.join(browsertrix_home, "profile.tar.gz")
|
|
||||||
shutil.copyfile(self.profile, profile_fn)
|
|
||||||
cmd.extend(["--profile", os.path.join("/crawls", "profile.tar.gz")])
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
logger.info(f"Running browsertrix-crawler: {' '.join(cmd)}")
|
logger.info(f"Running browsertrix-crawler: {' '.join(cmd)}")
|
||||||
@@ -99,18 +94,18 @@ class WaczArchiverEnricher(Enricher, Archiver):
|
|||||||
logger.error(f"WACZ generation failed: {e}")
|
logger.error(f"WACZ generation failed: {e}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if os.getenv('RUNNING_IN_DOCKER'):
|
if use_docker:
|
||||||
filename = os.path.join("collections", collection, f"{collection}.wacz")
|
wacz_fn = os.path.join(browsertrix_home_container, "collections", collection, f"{collection}.wacz")
|
||||||
else:
|
else:
|
||||||
filename = os.path.join(browsertrix_home, "collections", collection, f"{collection}.wacz")
|
wacz_fn = os.path.join("collections", collection, f"{collection}.wacz")
|
||||||
|
|
||||||
if not os.path.exists(filename):
|
if not os.path.exists(wacz_fn):
|
||||||
logger.warning(f"Unable to locate and upload WACZ {filename=}")
|
logger.warning(f"Unable to locate and upload WACZ {wacz_fn=}")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
to_enrich.add_media(Media(filename), "browsertrix")
|
to_enrich.add_media(Media(wacz_fn), "browsertrix")
|
||||||
if self.extract_media:
|
if self.extract_media:
|
||||||
self.extract_media_from_wacz(to_enrich, filename)
|
self.extract_media_from_wacz(to_enrich, wacz_fn)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def extract_media_from_wacz(self, to_enrich: Metadata, wacz_filename: str) -> None:
|
def extract_media_from_wacz(self, to_enrich: Metadata, wacz_filename: str) -> None:
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class WaybackArchiverEnricher(Enricher, Archiver):
|
|||||||
def configs() -> dict:
|
def configs() -> dict:
|
||||||
return {
|
return {
|
||||||
"timeout": {"default": 15, "help": "seconds to wait for successful archive confirmation from wayback, if more than this passes the result contains the job_id so the status can later be checked manually."},
|
"timeout": {"default": 15, "help": "seconds to wait for successful archive confirmation from wayback, if more than this passes the result contains the job_id so the status can later be checked manually."},
|
||||||
|
"if_not_archived_within": {"default": None, "help": "only tell wayback to archive if no archive is available before the number of seconds specified, use None to ignore this option. For more information: https://docs.google.com/document/d/1Nsv52MvSjbLb2PCpHlat0gkzw0EvtSgpKHu4mk0MnrA"},
|
||||||
"key": {"default": None, "help": "wayback API key. to get credentials visit https://archive.org/account/s3.php"},
|
"key": {"default": None, "help": "wayback API key. to get credentials visit https://archive.org/account/s3.php"},
|
||||||
"secret": {"default": None, "help": "wayback API secret. to get credentials visit https://archive.org/account/s3.php"}
|
"secret": {"default": None, "help": "wayback API secret. to get credentials visit https://archive.org/account/s3.php"}
|
||||||
}
|
}
|
||||||
@@ -50,7 +51,11 @@ class WaybackArchiverEnricher(Enricher, Archiver):
|
|||||||
"Accept": "application/json",
|
"Accept": "application/json",
|
||||||
"Authorization": f"LOW {self.key}:{self.secret}"
|
"Authorization": f"LOW {self.key}:{self.secret}"
|
||||||
}
|
}
|
||||||
r = requests.post('https://web.archive.org/save/', headers=ia_headers, data={'url': url})
|
post_data = {'url': url}
|
||||||
|
if self.if_not_archived_within:
|
||||||
|
post_data["if_not_archived_within"] = self.if_not_archived_within
|
||||||
|
# see https://docs.google.com/document/d/1Nsv52MvSjbLb2PCpHlat0gkzw0EvtSgpKHu4mk0MnrA for more options
|
||||||
|
r = requests.post('https://web.archive.org/save/', headers=ia_headers, data=post_data)
|
||||||
|
|
||||||
if r.status_code != 200:
|
if r.status_code != 200:
|
||||||
logger.error(em := f"Internet archive failed with status of {r.status_code}: {r.json()}")
|
logger.error(em := f"Internet archive failed with status of {r.status_code}: {r.json()}")
|
||||||
|
|||||||
@@ -18,17 +18,18 @@ class WhisperEnricher(Enricher):
|
|||||||
def __init__(self, config: dict) -> None:
|
def __init__(self, config: dict) -> None:
|
||||||
# without this STEP.__init__ is not called
|
# without this STEP.__init__ is not called
|
||||||
super().__init__(config)
|
super().__init__(config)
|
||||||
|
assert type(self.api_endpoint) == str and len(self.api_endpoint) > 0, "please provide a value for the whisper_enricher api_endpoint"
|
||||||
assert type(self.api_key) == str and len(self.api_key) > 0, "please provide a value for the whisper_enricher api_key"
|
assert type(self.api_key) == str and len(self.api_key) > 0, "please provide a value for the whisper_enricher api_key"
|
||||||
self.timeout = int(self.timeout)
|
self.timeout = int(self.timeout)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def configs() -> dict:
|
def configs() -> dict:
|
||||||
return {
|
return {
|
||||||
"api_endpoint": {"default": "https://whisper.spoettel.dev/api/v1", "help": "WhisperApi api endpoint"},
|
"api_endpoint": {"default": None, "help": "WhisperApi api endpoint, eg: https://whisperbox-api.com/api/v1, a deployment of https://github.com/bellingcat/whisperbox-transcribe."},
|
||||||
"api_key": {"default": None, "help": "WhisperApi api key for authentication"},
|
"api_key": {"default": None, "help": "WhisperApi api key for authentication"},
|
||||||
"include_srt": {"default": False, "help": "Whether to include a subtitle SRT (SubRip Subtitle file) for the video (can be used in video players)."},
|
"include_srt": {"default": False, "help": "Whether to include a subtitle SRT (SubRip Subtitle file) for the video (can be used in video players)."},
|
||||||
"timeout": {"default": 90, "help": "How many seconds to wait at most for a successful job completion."},
|
"timeout": {"default": 90, "help": "How many seconds to wait at most for a successful job completion."},
|
||||||
"action": {"default": "translation", "help": "which Whisper operation to execute", "choices": ["transcript", "translation", "language_detection"]},
|
"action": {"default": "translate", "help": "which Whisper operation to execute", "choices": ["transcribe", "translate", "language_detection"]},
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -56,9 +57,12 @@ class WhisperEnricher(Enricher):
|
|||||||
|
|
||||||
for i, m in enumerate(to_enrich.media):
|
for i, m in enumerate(to_enrich.media):
|
||||||
if m.is_video() or m.is_audio():
|
if m.is_video() or m.is_audio():
|
||||||
job_id = to_enrich.media[i].get("whisper_model")["job_id"]
|
job_id = to_enrich.media[i].get("whisper_model", {}).get("job_id")
|
||||||
|
if not job_id: continue
|
||||||
to_enrich.media[i].set("whisper_model", {
|
to_enrich.media[i].set("whisper_model", {
|
||||||
"job_id": job_id,
|
"job_id": job_id,
|
||||||
|
"job_status_check": f"{self.api_endpoint}/jobs/{job_id}",
|
||||||
|
"job_artifacts_check": f"{self.api_endpoint}/jobs/{job_id}/artifacts",
|
||||||
**(job_results[job_id] if job_results[job_id] else {"result": "incomplete or failed job"})
|
**(job_results[job_id] if job_results[job_id] else {"result": "incomplete or failed job"})
|
||||||
})
|
})
|
||||||
# append the extracted text to the content of the post so it gets written to the DBs like gsheets text column
|
# append the extracted text to the content of the post so it gets written to the DBs like gsheets text column
|
||||||
@@ -76,6 +80,7 @@ class WhisperEnricher(Enricher):
|
|||||||
"type": self.action,
|
"type": self.action,
|
||||||
# "language": "string" # may be a config
|
# "language": "string" # may be a config
|
||||||
}
|
}
|
||||||
|
logger.debug(f"calling API with {payload=}")
|
||||||
response = requests.post(f'{self.api_endpoint}/jobs', json=payload, headers={'Authorization': f'Bearer {self.api_key}'})
|
response = requests.post(f'{self.api_endpoint}/jobs', json=payload, headers={'Authorization': f'Bearer {self.api_key}'})
|
||||||
assert response.status_code == 201, f"calling the whisper api {self.api_endpoint} returned a non-success code: {response.status_code}"
|
assert response.status_code == 201, f"calling the whisper api {self.api_endpoint} returned a non-success code: {response.status_code}"
|
||||||
logger.debug(response.json())
|
logger.debug(response.json())
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ No URL available for {{ m.key }}.
|
|||||||
<a href="https://lens.google.com/uploadbyurl?url={{ url | quote }}">Google Lens</a>,
|
<a href="https://lens.google.com/uploadbyurl?url={{ url | quote }}">Google Lens</a>,
|
||||||
<a href="https://yandex.ru/images/touch/search?rpt=imageview&url={{ url | quote }}">Yandex</a>,
|
<a href="https://yandex.ru/images/touch/search?rpt=imageview&url={{ url | quote }}">Yandex</a>,
|
||||||
<a href="https://www.bing.com/images/search?view=detailv2&iss=sbi&form=SBIVSP&sbisrc=UrlPaste&q=imgurl:{{ url | quote }}">Bing</a>,
|
<a href="https://www.bing.com/images/search?view=detailv2&iss=sbi&form=SBIVSP&sbisrc=UrlPaste&q=imgurl:{{ url | quote }}">Bing</a>,
|
||||||
<a href="https://www.tineye.com/search/?url={{ url | quote }}">Tineye</a>,
|
<a href="https://www.tineye.com/search/?url={{ url | quote }}">Tineye</a>
|
||||||
</div>
|
</div>
|
||||||
<p></p>
|
<p></p>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ class GDriveStorage(Storage):
|
|||||||
'parents': [upload_to]
|
'parents': [upload_to]
|
||||||
}
|
}
|
||||||
media = MediaFileUpload(media.filename, resumable=True)
|
media = MediaFileUpload(media.filename, resumable=True)
|
||||||
gd_file = self.service.files().create(body=file_metadata, media_body=media, fields='id').execute()
|
gd_file = self.service.files().create(supportsAllDrives=True, body=file_metadata, media_body=media, fields='id').execute()
|
||||||
logger.debug(f'uploadf: uploaded file {gd_file["id"]} successfully in folder={upload_to}')
|
logger.debug(f'uploadf: uploaded file {gd_file["id"]} successfully in folder={upload_to}')
|
||||||
|
|
||||||
# must be implemented even if unused
|
# must be implemented even if unused
|
||||||
@@ -150,6 +150,9 @@ class GDriveStorage(Storage):
|
|||||||
|
|
||||||
for attempt in range(retries):
|
for attempt in range(retries):
|
||||||
results = self.service.files().list(
|
results = self.service.files().list(
|
||||||
|
# both below for Google Shared Drives
|
||||||
|
supportsAllDrives=True,
|
||||||
|
includeItemsFromAllDrives=True,
|
||||||
q=query_string,
|
q=query_string,
|
||||||
spaces='drive', # ie not appDataFolder or photos
|
spaces='drive', # ie not appDataFolder or photos
|
||||||
fields='files(id, name)'
|
fields='files(id, name)'
|
||||||
@@ -182,7 +185,7 @@ class GDriveStorage(Storage):
|
|||||||
'mimeType': 'application/vnd.google-apps.folder',
|
'mimeType': 'application/vnd.google-apps.folder',
|
||||||
'parents': [parent_id]
|
'parents': [parent_id]
|
||||||
}
|
}
|
||||||
gd_folder = self.service.files().create(body=file_metadata, fields='id').execute()
|
gd_folder = self.service.files().create(supportsAllDrives=True, body=file_metadata, fields='id').execute()
|
||||||
return gd_folder.get('id')
|
return gd_folder.get('id')
|
||||||
|
|
||||||
# def exists(self, key):
|
# def exists(self, key):
|
||||||
|
|||||||
@@ -52,6 +52,19 @@ class UrlUtil:
|
|||||||
# telegram
|
# telegram
|
||||||
if "https://telegram.org/img/emoji/" in url: return False
|
if "https://telegram.org/img/emoji/" in url: return False
|
||||||
|
|
||||||
|
# youtube
|
||||||
|
if "https://www.youtube.com/s/gaming/emoji/" in url: return False
|
||||||
|
if "https://yt3.ggpht.com" in url and "default-user=" in url: return False
|
||||||
|
if "https://www.youtube.com/s/search/audio/" in url: return False
|
||||||
|
|
||||||
|
# ok
|
||||||
|
if " https://ok.ru/res/i/" in url: return False
|
||||||
|
|
||||||
|
# vk
|
||||||
|
if "https://vk.com/emoji/" in url: return False
|
||||||
|
if "vk.com/images/" in url: return False
|
||||||
|
if "vk.com/images/reaction/" in url: return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ _MAJOR = "0"
|
|||||||
_MINOR = "6"
|
_MINOR = "6"
|
||||||
# On main and in a nightly release the patch should be one ahead of the last
|
# On main and in a nightly release the patch should be one ahead of the last
|
||||||
# released build.
|
# released build.
|
||||||
_PATCH = "2"
|
_PATCH = "13"
|
||||||
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
|
||||||
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
# https://semver.org/#is-v123-a-semantic-version for the semantics.
|
||||||
_SUFFIX = ""
|
_SUFFIX = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user