Allow specifying session files with .session extension at command line

This commit is contained in:
Alessio 2023-03-16 17:50:36 -03:00
parent 6f2ef8953b
commit a724f32470
2 changed files with 8 additions and 0 deletions

View File

@ -319,6 +319,9 @@ test "$(sqlite3 twitter.db "select count(*) from tweets where id = 1562714727968
tw --session Offline_Twatter fetch_tweet_only https://twitter.com/PandasAndVidya/status/1562714727968428032
test "$(sqlite3 twitter.db "select count(*) from tweets where id = 156271472796842803")" == "0"
# Test that you can pass a session with the `.session` file extension too
tw --session Offline_Twatter.session list_followed > /dev/null # Dummy operation
# TODO: Maybe this file should be broken up into multiple test scripts
echo -e "\033[32mAll tests passed. Finished successfully.\033[0m"

View File

@ -6,6 +6,7 @@ import (
log "github.com/sirupsen/logrus"
"golang.org/x/term"
"os"
"strings"
"syscall"
"offline_twitter/persistence"
@ -94,6 +95,10 @@ func main() {
}
if *session_name != "" {
if strings.HasSuffix(*session_name, ".session") {
// Lop off the ".session" suffix (allows using `--session asdf.session` which lets you tab-autocomplete at command line)
*session_name = (*session_name)[:len(*session_name)-8]
}
scraper.InitApi(profile.LoadSession(scraper.UserHandle(*session_name)))
// fmt.Printf("Operating as user: @%s\n", scraper.the_api.UserHandle)
} else {