stockbsd 2019-10-24 16:34:12 +08:00
rodzic a2fd8d52d2
commit d7460a0e10
5 zmienionych plików z 18 dodań i 21 usunięć

Wyświetl plik

@ -9,14 +9,15 @@ pip3 install twitter-dl
``` ```
usage: twitter-dl [-h] [-c CONFIDENTIAL] usage: twitter-dl [-h] [-c CONFIDENTIAL]
[-s {large,medium,small,thumb,orig}] [-s {large,medium,small,thumb,orig}]
[--tweet] [--video] [--nophoto] [--video] [--nophoto]
[-l LIMIT] [--rts] [-l LIMIT] [--rts]
[--thread-number THREAD_NUMBER] [--thread-number THREAD_NUMBER]
[--coro-number CORO_NUMBER] [--coro-number CORO_NUMBER]
[--since SID] [--since SID]
[--tweet] [--list]
resource_id dest resource_id dest
Download all images uploaded by a twitter user you specify Download all images and/or videos uploaded by a twitter user you specify
positional arguments: positional arguments:
resource_id An ID of a twitter user. Also accept tweet url or resource_id An ID of a twitter user. Also accept tweet url or
@ -29,12 +30,12 @@ optional arguments:
a json file containing a key and a secret a json file containing a key and a secret
-s {large,medium,small,thumb,orig}, --size {large,medium,small,thumb,orig} -s {large,medium,small,thumb,orig}, --size {large,medium,small,thumb,orig}
specify the size of images specify the size of images
--tweet indicate you gived a tweet url or tweet id --tweet indicate resource_id is a numbered tweet id
--list indicate resource_id is a list (user:slug)
--video include video --video include video
--nophoto exclude photo --nophoto exclude photo
-l LIMIT, --limit LIMIT -l LIMIT, --limit LIMIT
the maximum number of tweets to check (most recent the maximum number of tweets to check (most recent first)
first)
--rts save images contained in retweets --rts save images contained in retweets
--thread-number THREAD_NUMBER --thread-number THREAD_NUMBER
--coro-number CORO_NUMBER --coro-number CORO_NUMBER

Wyświetl plik

@ -18,11 +18,10 @@ def get_version():
return version return version
raise RuntimeError("Unable to find version string in %s" % version_file) raise RuntimeError("Unable to find version string in %s" % version_file)
name = "twitter-dl" git_repo = "https://github.com/stockbsd/twitter-media-dl"
git_repo = "https://github.com/stockbsd/{}".format(name)
setup( setup(
name=name, name="twitter-dl", #distribution name
version=get_version(), version=get_version(),
description="Download tweet images and videos", description="Download tweet images and videos",
long_description=Readme, long_description=Readme,
@ -37,7 +36,7 @@ setup(
url=git_repo, url=git_repo,
author="stockbsd", author="stockbsd",
author_email="stockbsd@gmail.com", author_email="stockbsd@gmail.com",
keywords="twitter", keywords="twitter, asyncio, media",
project_urls={"Bug Reports": git_repo, "Source": git_repo}, project_urls={"Bug Reports": git_repo, "Source": git_repo},
classifiers=[ classifiers=[
"Programming Language :: Python :: 3", "Programming Language :: Python :: 3",

Wyświetl plik

@ -1,3 +1,3 @@
from .downloader import Downloader from .downloader import Downloader
version = "0.1.3" version = "0.1.4"

Wyświetl plik

@ -1,11 +1,9 @@
import os import os
import argparse import argparse
import json import json
import re
import logging import logging
from . import Downloader from . import Downloader
from .exceptions import *
def main(): def main():
@ -36,13 +34,13 @@ def main():
) )
parser.add_argument( parser.add_argument(
"--tweet", "--tweet",
help="indicate you gived a tweet url or tweet id", help="indicate you gived a tweet id",
default=False, default=False,
action="store_true", action="store_true",
) )
parser.add_argument( parser.add_argument(
"--list", "--list",
help="indicate you gived a list by user:list", help="indicate you gived a list by user:slug",
default=False, default=False,
action="store_true", action="store_true",
) )
@ -76,11 +74,11 @@ def main():
with open(args.confidential) as f: with open(args.confidential) as f:
confidential = json.loads(f.read()) confidential = json.loads(f.read())
if "consumer_key" not in confidential or "consumer_secret" not in confidential: if "consumer_key" not in confidential or "consumer_secret" not in confidential:
raise ConfidentialsNotSuppliedError() raise RuntimeError("Confidentials Not Supplied")
api_key = confidential["consumer_key"] api_key = confidential["consumer_key"]
api_secret = confidential["consumer_secret"] api_secret = confidential["consumer_secret"]
else: else:
raise ConfidentialsNotSuppliedError(args.confidential) raise RuntimeError("Confidentials Not Supplied")
downloader = Downloader(api_key, api_secret, args.thread_number, args.coro_number) downloader = Downloader(api_key, api_secret, args.thread_number, args.coro_number)

Wyświetl plik

@ -6,7 +6,6 @@ import json
import requests import requests
from .exceptions import *
from .threaded_aio_dlder import AioDownloader from .threaded_aio_dlder import AioDownloader
@ -50,7 +49,7 @@ class Downloader:
if r.status_code == 200: if r.status_code == 200:
return r.json()["access_token"] return r.json()["access_token"]
else: else:
raise BearerTokenNotFetchedError() raise RuntimeError("Bearer TokenNot Fetched")
def download_media_of_tweet(self, tid, save_dest, size="large", include_video=False, def download_media_of_tweet(self, tid, save_dest, size="large", include_video=False,
include_photo=True): include_photo=True):