Browse Source

Add support for Twitter hashtag extraction

master
JustAnotherArchivist 1 year ago
parent
commit
679923d37d
2 changed files with 12 additions and 3 deletions
  1. +1
    -1
      snscrape-extract
  2. +11
    -2
      snscrape-prepare-commands

snscrape-extract-usernames → snscrape-extract View File

@@ -1,7 +1,7 @@
#!/bin/bash
# Extract from stdin social media usernames suitable for snscrape, grouped by service
grep -Po '(https?://www\.\Kfacebook\.com/(?!pages/)\S+(?=/)|https?://www\.\Kinstagram\.com/\S+(?=/)|https?://\Ktwitter\.com/\S+)' |
sed 's,\.com/, ,' |
sed 's,\.com/, ,; s,^twitter hashtag/,twitter-hashtag ,; s,twitter ,twitter-user ,' |
sort |
awk '
BEGIN {

+ 11
- 2
snscrape-prepare-commands View File

@@ -1,9 +1,18 @@
#!/bin/bash
scriptpath="$(cd "$(dirname "$0")"; pwd -P)"

"${scriptpath}/snscrape-extract-usernames" | while read -r service line
"${scriptpath}/snscrape-extract" | while read -r service line
do
if [[ "${service}" == "facebook:" || "${service}" == "instagram:" || "${service}" == "twitter:" ]]
if [[ "${service}" == "facebook:" ]]
then
echo "printf '%s\n' ${line} | parallel -n 1 -k -j 4 $(printf "%q" "${scriptpath}")/snscrape-facebook-user"
elif [[ "${service}" == "twitter-hashtag:" ]]
then
echo "printf '%s\n' ${line} | parallel -n 1 -k -j 3 $(printf "%q" "${scriptpath}")/snscrape-twitter-hashtag"
elif [[ "${service}" == "twitter-user:" ]]
then
echo "printf '%s\n' ${line} | parallel -n 1 -k -j 3 $(printf "%q" "${scriptpath}")/snscrape-twitter-user"
elif [[ "${service}" == "instagram:" ]]
then
echo "for user in ${line}; do $(printf "%q" "${scriptpath}")/snscrape-${service:0:-1}-user "'"${user}"; done'
fi


Loading…
Cancel
Save