mirror of
https://github.com/bellingcat/snscrape.git
synced 2026-06-11 03:48:29 +03:00
Deprecate Entity type
There is no meaningful distinction from Items, and it complicates the integration of scrapers for user searches
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
__all__ = ['DeprecatedFeatureWarning', 'IntWithGranularity', 'Item', 'Scraper', 'ScraperException']
|
||||
|
||||
|
||||
import abc
|
||||
import copy
|
||||
import dataclasses
|
||||
@@ -97,7 +100,7 @@ class _JSONDataclass:
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Item(_JSONDataclass):
|
||||
'''An abstract base class for an item returned by the scraper's get_items generator.
|
||||
'''An abstract base class for an item returned by the scraper.
|
||||
|
||||
An item can really be anything. The string representation should be useful for the CLI output (e.g. a direct URL for the item).
|
||||
'''
|
||||
@@ -107,18 +110,6 @@ class Item(_JSONDataclass):
|
||||
pass
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Entity(_JSONDataclass):
|
||||
'''An abstract base class for an entity returned by the scraper's entity property.
|
||||
|
||||
An entity is typically the account of a person or organisation. The string representation should be the preferred direct URL to the entity's page on the network.
|
||||
'''
|
||||
|
||||
@abc.abstractmethod
|
||||
def __str__(self):
|
||||
pass
|
||||
|
||||
|
||||
class IntWithGranularity(int):
|
||||
'''A number with an associated granularity
|
||||
|
||||
@@ -296,3 +287,6 @@ def nonempty_string(name):
|
||||
raise ValueError('must not be an empty string')
|
||||
f.__name__ = name
|
||||
return f
|
||||
|
||||
|
||||
__getattr__, __dir__ = _module_deprecation_helper(__all__, Entity = Item)
|
||||
|
||||
@@ -30,7 +30,7 @@ class FacebookPost(snscrape.base.Item):
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
username: str
|
||||
pageId: int
|
||||
name: str
|
||||
|
||||
@@ -32,7 +32,7 @@ class InstagramPost(snscrape.base.Item):
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
username: str
|
||||
name: typing.Optional[str]
|
||||
followers: snscrape.base.IntWithGranularity
|
||||
|
||||
@@ -67,7 +67,7 @@ class PollOption:
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
account: str # @username@domain.invalid
|
||||
displayName: typing.Optional[str] = None
|
||||
displayNameWithCustomEmojis: typing.Optional[typing.List[typing.Union[str, 'CustomEmoji']]] = None
|
||||
|
||||
@@ -39,7 +39,7 @@ class TelegramPost(snscrape.base.Item):
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Channel(snscrape.base.Entity):
|
||||
class Channel(snscrape.base.Item):
|
||||
username: str
|
||||
title: str
|
||||
verified: bool
|
||||
|
||||
@@ -457,7 +457,7 @@ class Tombstone(snscrape.base.Item):
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
# Most fields can be None if they're not known.
|
||||
|
||||
username: str
|
||||
@@ -513,7 +513,7 @@ class UserRef:
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Community(snscrape.base.Entity):
|
||||
class Community(snscrape.base.Item):
|
||||
id: int
|
||||
name: str
|
||||
description: str
|
||||
|
||||
@@ -75,7 +75,7 @@ class Video:
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
username: str
|
||||
name: str
|
||||
verified: bool
|
||||
|
||||
@@ -34,7 +34,7 @@ class Post(snscrape.base.Item):
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class User(snscrape.base.Entity):
|
||||
class User(snscrape.base.Item):
|
||||
screenname: str
|
||||
uid: int
|
||||
verified: bool
|
||||
|
||||
Reference in New Issue
Block a user