Tweepy getting full tweet text - twitter

I am using the following code to retrieve the tweets using Tweepy API:
try:
text="retweeted: "+json_reply['retweeted_status']['text']
user_name ="retweeted: "+json_reply['retweeted_status']['user']['screen_name']
except:
text=json_reply['text']
user_name=json_reply['user']['screen_name']
I am getting the following output tweets which do not match my expectations.
1) retweeted: M67 | Open Cluster in Cancer One of the oldest clusters in the Milky Way Often overlooked because of its neighbor M… [url here]
2) There may be a flurry of activity in your life today even if ... More for Cancer [url here]
My expectation is that both these should not contain the elipsis. What am I doing wrong here?

There is now an extended mode in the Twitter API to handle this case.
For instance, with tweepy (Python), you can get the full text using tweet_mode='extended' (not documented in the Tweepy doc). For instance:
print api.get_status('862328512405004288')._json['text']
#tousuncotefoot #equipedefrance #CreditAgricole #AntoGriezmann #KMbappe #layvinkurzawa #UmtitiSam J'ai jamais vue d… https://tco/kALZ2ki9Vc
print api.get_status('862328512405004288', tweet_mode='extended')._json['full_text']
#tousuncotefoot #equipedefrance #CreditAgricole #AntoGriezmann #KMbappe #layvinkurzawa #UmtitiSam J'ai jamais vue de match de foot et cela ferait un beau cadeau pour mon copain !! 🙏🏻🙏🏻🙏🏻😍😍

Related

Emotional TTS with Amazon Polly's SSML tags

Polly allows the use of SSML tags which is great, but I cannot seem to find a tag that would add some kinds emotion. Let's refer to this as Emotional TTS. For instance, the following snippet:
<speak> Hi! My name is Joshua. </speak>
<speak> Hoi! Mijn naam is Lotte. <break time="3s" /> Ik lees elke tekst voor die je hier invoert. </speak>
Is it possible to do Emotional TTS with Polly; e.g. "aaaws" and "aaahs" with Polly? I guess if it were, it would have to be via SSML. Right? How would I modify the above to facilitate such a thing?
If you are using Alexa, depending on language, you might be able to achieve some of this with speechcons:
<speak>
Not quite "aah", but almost:
<say-as interpret-as="interjection">argh</say-as>.
</speak>
See the supported list of speechcons and more details on:
https://developer.amazon.com/en-GB/docs/alexa/custom-skills/speechcon-reference-interjections-english-us.html
Unfortunately, Amazon Polly does not support interjections as of August 2021. You can try it interactively in the browser with the code above, which gives me:
The input you provided isn't valid. Check the input, and then try again.

https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("ARSARS")&env=store://datatables.org/alltableswithkeys

I have been using the following URL for the past 3 years without issue. However, it has stopped returning results.
URL:
https://query.yahooapis.com/v1/public/yql?q=select * from yahoo.finance.xchange where pair in ("ARSARS")&env=store://datatables.org/alltableswithkeys
Now returns the following:
<?xml version="1.0" encoding="UTF-8"?>
<query xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" yahoo:count="0" yahoo:created="2017-11-02T09:33:25Z" yahoo:lang="en-AU">
<results/>
</query><!-- total: 9 -->
Notice how there are no results, it simply has the tag "results".
I have tried on this many different computers and browsers. I have also tried changing the currency combinations, but no luck.
Can anybody spot what I am doing wrong?
Yes, it looks like Yahoo has discontinued their Currency Converter API service.
I found a different site : https://currencylayer.com/
They let you request currency rates (1 USD = 168 other currencies). If you make less than 1000 requests per month, it is free (if you need more, they have different subscriptions : https://currencylayer.com/product).
You just need to sign up and receive your own Access Code. Once you have that, then you simply make the call http://apilayer.net/api/live?access_key= and it will return JSON of the other currency rates.
They also have code examples in PHP, JavaScript, and Java at https://currencylayer.com/documentation
Found it very easy to get started using their API right away.
I think the API is down.
I am similarly receiving "results"=nullfor the query:
http://query.yahooapis.com/v1/public/yql?q=select+%2A+from+yahoo.finance.xchange+where+pair+in+%28%22GBPEUR%22%29&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys
Setting diagnostics=true in the request yields:
`
[execution-start-time] => 7
[execution-stop-time] => 12
[execution-time] => 5
[http-status-code] => 999
[http-status-message] => Request denied
[content] => http://download.finance.yahoo.com/d/quotes.csv?s=GBPEUR=X&f=snl1d1t1ab
`
If anyone knows more than me about what this might imply I'd be glad to hear it!
Yahoo is aware of this issue and their engineers are working on it:
ref: https://forums.yahoo.net/t5/Yahoo-Finance-help/http-download-finance-yahoo-com-d-quotes-csv-s-GOOG-amp-f/td-p/387096
Very sadly and quite outrageously Yahoo decided to stop this service without any warning.
See admin message here
So many services depend on it, it's like Google saying they would suddenly stop their maps API... At this point I am blocking yahoo in our DNS so no one in our company will ever use Yahoo again since they are not a reliable entity.

Why the email I send via the INSTRUCTOR > EMAILS is truncated?

1) Given my email, produced via a mailchimp online editor.
2) I go to my openEdX, log in as administrator of the MOOC. Then got to My MOOC > INSTRUCTOR > EMAILS, in order to send my email. First a test to myself, later to my 2000 mooc students.
3) The email I receive in my inbox is CUT HALF WAY. The bottom part is all missing.
QUESTION : What is going on there ? How to fix this ?
Look into your code for the first paragraph which disapeared. It's likely the buggy part.
For this case, I can see the first disappeared sentence is :
💡 Astuce : Pensez à inviter NudiMooc à suivre votre BLOG
My eyes are catched up by the strange 💡 sign, which is a rare unicode character.
Delete this exotic 💡 sign from your email / html5 code, and it will work again. I tested it by sending to myself. Horray ! The corrected code without the lightbulb was complete !! :D
OpenEdX processing may crash on this string. But because there are some witty security, the previous, valid text is kept.

Google Translate Save to Phrasebook Import - GET/POST Hack

I have bunch of words saved in plain text file and a I would like to import them to Google Translate somehow. They should then be visible in new Google Translate feature, Phrasebook. So what I did so far is that I've opened Google Translate page with enabled FireBug and enter word "feuds". The results are following:
GET /translate/releases/twsfe_w_20130506_RC02/r/js/desktop_module_lazy.js
GET /translate/releases/twsfe_w_20130506_RC02/r/js/desktop_module_lazy.js
GET /translate_a/t?client=t&hl=en&sl=auto&tl=sk&ie=UTF-8&oe=UTF-8&multires=1&ssel=0&tsel=0&uptl=sk&sc=1&q=feuds
POST https://plus.google.com/u/0/_/n/gcosuc?origin=http%3A%2F%2Ftranslate.google.com
200 OK
103ms
>>>
################################################
### AFTER PRESSING SAVE TO PHRASEBOOK BUTTON ###
################################################
POST /translate_a/sg?client=t&cm=a&sl=en&tl=sk&ql=5&hl=en&xt=ALkJrhgAAAAAUZvTtWm7IqJAYJpay1AU8x-VoS_AM0J0
client t
cm a
hl en
ql 5
sl en
tl sk
xt ALkJrhgAAAAAUZvTtWm7IqJAYJpay1AU8x-VoS_AM0J0
200 OK
137ms
>>>
GET /translate_a/sg?client=t&cm=g&tk=8mXp7vd2yN4UVnN8_Bw51LnXE2wqfQI&hl=en&xt=ALkJrhgAAAAAUZvTtWm7IqJAYJpay1AU8x-VoS_AM0J0
client t
cm g
hl en
tk 8mXp7vd2yN4UVnN8_Bw51LnXE2wqfQI
xt ALkJrhgAAAAAUZvTtWm7IqJAYJpay1AU8x-VoS_AM0J0
200 OK
112ms
>>>
You can see that on 3rd GET the word is available "&q=feuds" But what happens when I press "Save to Phrasebook"? It seems that there is sending source language (sl), target language (tl) etc. with some strange string: "ALkJrhgAAAAAUZvTtWm7IqJAYJpay1AU8x-VoS_AM0J0" which might be my "hashed" word. Another idea which comes to my mind is that this strange string did not have to bee "hashed" word necessary, but it might be for example some ID, which refers to word that I have typed in the past (in this case few seconds ago until I hit "Save to Phrasebook" button). Is it possible to somehow "decode" this string?
I have noticed that this "xt" value is received in 1st response from "translate.google.com", look for variable with name "USAGE".
Also I have found that "xt" value appear in all requests related to Phrasebook (example: show phrasebook, add/delete word to/from phrasebook), and in each new google translator page you will have new "xt" value.
Based on this, can assume, that "xt" variable implement function of identification token for Phrasebook.

Tracking multiple hashtags using twitter stream API

When I access (w/ proper credentials):
https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help'
I get what I want: an unending stream of tweets with the #help hashtag.
However,
https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help,#perl
yields the error
Illegal character in fragment at index 70:
https://stream.twitter.com/1/statuses/filter.json?lang=en&track=#help,#perl
which appears to be the '#' in '#perl'. How to fix?
For reference, this works fine:
https://stream.twitter.com/1/statuses/filter.json?lang=en&track=perl,#help
while this does not:
https://stream.twitter.com/1/statuses/filter.json?lang=en&track=perl,#help,#ruby
Is there a rule re not tracking more than one hashtag, or am I doing
something more fundamentally wrong? Should I track '#hashtag' by just
tracking 'hashtag'?
['term1,term2']
But what about the hashtags? This link says not to use them: https://dev.twitter.com/streaming/overview/request-parameters#track
We can remove the apostrophes and spaces (in python) with
upgrades_str = re.sub('[\' \[\]]', '', upgrades_str)
upgrades_str = '[\''+format(upgrades_str)+'\']'

Resources