chiark / gitweb /
Parse video objects less stoatily
authorTom Womack <tom@womack.net>
Wed, 26 Jun 2019 20:34:53 +0000 (21:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Wed, 26 Jun 2019 22:08:14 +0000 (23:08 +0100)
commitf024eaca7f9d7ddf1acaae2d0849544d5e857800
tree6545ed978bc758bc82250b86e29062a5967d49fe
parent532656ca33d5309407b1c7c003a666dc0788258b
Parse video objects less stoatily

The https://github.com/bear/python-twitter API throws away the
extended-information field in which the name of the video file is stored;
so parse the JSON again ourselves to get hold of it.

Pick the highest bit rate MP4 video.

Throw away the old ad-hoc mangling of video_thumb urls; that is no
longer needed.

Signed-off-by: Tom Womack <tom@womack.net>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
---
v2:

 Fix logic error:
    When tweet contains multiple media, handle videos as videos and
    non-videos as non-videos.  Resulting patch has rather different
    organisation and does less violence to the original code.

 Commit message changes:
    Mention deletion of tweet_video_thumb hack

 Style fixes and changes:
    Do not add a comment about the new import
    Use .get(DEFVAL) rather than nesting in if KEY in VAL, throughout
    Reformat new comment about JSON parsing to 80 columns
    Use ' rather than " for protocol elements such as hash keys
    Use split rather than a regexp to trim ? part from url
    Comments say "we" do something, not "I".
    When searching for the best, have a single `best' variable
    Divide float by float not int
    Adjust new replacement string construction to be more natural
    Be consistent about spaces around ==
commands.py