-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from booxter/new-directors
Complete directors list fetch
- Loading branch information
Showing
16 changed files
with
242,052 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -xe | ||
|
||
tdir=$(mktemp -d) | ||
echo "$tdir" | ||
for country in $(fetch-countries); do | ||
echo "Applying country: $country" | ||
fetch-country-list -N -c "$country" -o "$tdir/list.csv" | ||
fetch-directors -i "$tdir/list.csv" -o "$tdir/directors.csv" | ||
populate-directors -d "$tdir/directors.csv" | ||
make run-update-directors # fetch all films after each list so that "film already known" heuristic considers just added directors/movies | ||
rm "$tdir/*.csv" | ||
done | ||
echo "Done applying countries; results are in $tdir" | ||
# rm -rf $tdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
# https://letterboxd.com/eternalalien/list/all-narrative-feature-films-on-letterboxd/ | ||
# https://letterboxd.com/narpjay/list/exploitation-films-b-movie-cheese-grindhouse/ | ||
# https://letterboxd.com/seanmcgann98/list/sleazemovies-erotiga/ | ||
# https://letterboxd.com/mishima24/list/the-most-comprehensive-list-of-japanese-movies/ | ||
# https://letterboxd.com/ashleylynch/list/rarelust-complete-list/ | ||
# https://letterboxd.com/giniyapp/list/the-celluloid-void-rare-films-written-and/ | ||
# https://letterboxd.com/aopisaac/list/video-galactica-a-virtual-video-store-11293/ | ||
# https://letterboxd.com/sadhomersimpson/list/criterion/ | ||
# https://letterboxd.com/natethecyborg/list/every-film-available-on-the-criterion-channel/ | ||
# https://letterboxd.com/smiskfisk/list/almost-every-title-from-worldscinemaorg/ | ||
# https://letterboxd.com/robbob01/list/public-domain/ | ||
# https://letterboxd.com/ru6yy/list/every-movie-of-every-actor-actress-ive-seen/ | ||
# https://letterboxd.com/xob/list/films-of-interest-that-are-available-in-full/ | ||
# https://letterboxd.com/000_leo/list/every-film-ever-eligible-for-the-oscars/ | ||
# https://letterboxd.com/kordian86/list/list-of-polish-movies-1902-2023/ | ||
# https://letterboxd.com/ryokohakubi/list/a-comprehensive-animation-list/ | ||
# https://letterboxd.com/astroturd/list/no-average-rating/ | ||
# https://letterboxd.com/adamrant/list/the-definitive-films-about-film-list/ | ||
# https://letterboxd.com/terje_jr/list/struggles-of-the-global-south-in-progress/ | ||
# https://letterboxd.com/nodadyoushutup/list/nodadyoushutup-plex/ | ||
# https://letterboxd.com/marconerix/list/balkan-movies/ | ||
# https://letterboxd.com/solidaritycine/list/solidarity-cinema-archive/ | ||
# https://letterboxd.com/dessaint/list/best-korean/ | ||
# https://letterboxd.com/dmytro_malyar/list/ukrainian-films/ | ||
# https://letterboxd.com/bratofthe1980s/list/the-european-boys-adventure-tale/ | ||
# https://letterboxd.com/butterbud/list/the-working-class/ | ||
# https://letterboxd.com/jim13/list/cold-war-films/ | ||
# https://letterboxd.com/adarksong/list/films-from-classic-films-channel-to-watch/ | ||
# https://letterboxd.com/magrosleau/list/psychosexual-dramas-nihilistic-fever-dreams/ | ||
# https://letterboxd.com/evilbjork/list/avant-garde-underground/ | ||
# https://letterboxd.com/knuffeltje/list/zero-watches/ | ||
# https://letterboxd.com/artyficial/list/the-oxford-history-of-world-cinema/ | ||
# https://letterboxd.com/loureviews/list/i-l3ve-musicals/ | ||
# https://letterboxd.com/mitramitra/list/the-iran-archive-everything-wip/ | ||
# https://letterboxd.com/juliec/list/neverending-christmas-movie-list/ | ||
# https://letterboxd.com/stottiain/list/great-big-list-of-classic-cartoons/ | ||
# https://letterboxd.com/kodifranzese/list/kodi-franzeses-non-usa-foreign-filmography/ | ||
# https://letterboxd.com/timonist/list/east-germany/ | ||
# https://letterboxd.com/rhettman417/list/movies-on-rarefilmmcom/ | ||
# https://letterboxd.com/pakejanek/list/okru/ | ||
# https://letterboxd.com/liveandrew/list/genre-exploitation-100-years-1896-1995/ | ||
# https://letterboxd.com/gabrmachado/list/brazilian-cinema/ | ||
urls=( | ||
"https://letterboxd.com/sr0man/list/erotic/" | ||
"https://letterboxd.com/dustin_b/list/films-i-own-the-complete-mega-load/" | ||
"https://letterboxd.com/smlibrary/list/okay/" | ||
"https://letterboxd.com/retinaburn/list/the-most-comprehensive-list-of-hong-kong/" | ||
"https://letterboxd.com/wolfman07/list/every-horror-film-ever-made-1/" | ||
"https://letterboxd.com/infinityinc/list/every-tv-movie-aired-on-american-television/" | ||
"https://letterboxd.com/kaijufan67/list/the-bad-taste-list-weird-wild-psychotronic/" | ||
"https://letterboxd.com/buttersgreer/list/ultimate-list-of-every-movie-musical/" | ||
"https://letterboxd.com/natethecyborg/list/every-film-available-on-the-criterion-channel/" | ||
"https://letterboxd.com/mishima24/list/the-most-comprehensive-list-of-japanese-movies/" | ||
"https://letterboxd.com/elmiko_/list/every-animated-film-made-from-1878-present/" | ||
"https://letterboxd.com/clowchan/list/every-horror-film-made-from-1895-present/" | ||
) | ||
|
||
tdir=$(mktemp -d) | ||
echo "$tdir" | ||
for url in "${urls[@]}"; do | ||
echo "Applying list from url: $url" | ||
fetch-lb-list -N -u "$url" -o "$tdir/list.csv" | ||
fetch-directors -N -i "$tdir/list.csv" -o "$tdir/directors.csv" | ||
populate-directors -d "$tdir/directors.csv" | ||
make run-all # fetch all films after each list so that "film already known" heuristic considers just added directors/movies | ||
done | ||
echo "Done applying lists; results are in $tdir" | ||
# rm -rf $tdir |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import sys | ||
|
||
from bs4 import BeautifulSoup | ||
|
||
from letsrolld import http | ||
|
||
|
||
def main(): | ||
# fetch film list | ||
url = "https://letterboxd.com/countries/" | ||
content = http.get_url(url) | ||
|
||
soup = BeautifulSoup(content, "html.parser") | ||
|
||
countries_section = soup.find("div", class_="browse-countries") | ||
if countries_section is None: | ||
print("No countries section found") | ||
sys.exit(1) | ||
|
||
for a in countries_section.find_all("a"): | ||
href = a.get("href") | ||
if not href.startswith("/films/country/"): | ||
continue | ||
print(href.split("/")[-2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import argparse | ||
import csv | ||
import sys | ||
|
||
from sqlalchemy.orm import sessionmaker | ||
|
||
from letsrolld import db | ||
from letsrolld.db import models | ||
from letsrolld import lb_list | ||
|
||
|
||
# TODO: move to common module, reuse everywhere | ||
def is_known_film(film_): | ||
session = sessionmaker(bind=db.create_engine())() | ||
film = session.query(models.Film).filter(models.Film.lb_url == film_.url).first() | ||
if film is not None: | ||
print(f"Skipping known film: {film_.url}") | ||
sys.stdout.flush() | ||
return True | ||
return False | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-c", "--country", help="country slug", required=True) | ||
parser.add_argument("-o", "--output", help="output film list file", required=True) | ||
parser.add_argument( | ||
"-N", | ||
"--new-only", | ||
help="whether to filter out movies already present in db", | ||
action="store_true", | ||
) | ||
args = parser.parse_args() | ||
|
||
# fetch film list | ||
films = lb_list.MovieCountryList(args.country).films() | ||
|
||
if args.new_only: | ||
films = (film for film in films if not is_known_film(film)) | ||
|
||
# write to file | ||
with open(args.output, "w", newline="") as csvfile: | ||
writer = csv.writer(csvfile, dialect=csv.unix_dialect) | ||
writer.writerow(["Name", "Year", "URL"]) | ||
|
||
for film_ in films: | ||
while True: | ||
try: | ||
writer.writerow([film_.name, film_.year, film_.url]) | ||
break | ||
except Exception: | ||
print(f"Error writing film: {film_.url}") | ||
sys.stdout.flush() | ||
continue | ||
csvfile.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import argparse | ||
import csv | ||
import sys | ||
|
||
from sqlalchemy.orm import sessionmaker | ||
|
||
from letsrolld import db | ||
from letsrolld.db import models | ||
from letsrolld import lb_list | ||
|
||
|
||
# TODO: move to common module, reuse everywhere | ||
def is_known_film(film_): | ||
session = sessionmaker(bind=db.create_engine())() | ||
film = session.query(models.Film).filter(models.Film.lb_url == film_.url).first() | ||
if film is not None: | ||
print(f"Skipping known film: {film_.url}") | ||
sys.stdout.flush() | ||
return True | ||
return False | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("-u", "--url", help="list URL", required=True) | ||
parser.add_argument("-o", "--output", help="output film list file", required=True) | ||
parser.add_argument( | ||
"-N", | ||
"--new-only", | ||
help="whether to filter out movies already present in db", | ||
action="store_true", | ||
) | ||
args = parser.parse_args() | ||
|
||
# fetch film list | ||
films = lb_list.MovieList(args.url).films() | ||
|
||
if args.new_only: | ||
films = (film for film in films if not is_known_film(film)) | ||
|
||
# write to file | ||
with open(args.output, "w", newline="") as csvfile: | ||
writer = csv.writer(csvfile, dialect=csv.unix_dialect) | ||
writer.writerow(["Name", "Year", "URL"]) | ||
|
||
for film_ in films: | ||
writer.writerow([film_.name, film_.year, film_.url]) | ||
csvfile.flush() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.