mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-02 12:56:24 -05:00
Moving non-video functions to wrolpi.common. Handling Channel/Downlaod relationship in Channel.update.
Removing default download freqeuncy so channels will not be downloaded without a url and frequency. Adding channel unique url constraint. Handling when a Channel's directory may still be relative in DB. Adding TODOs to remove old favorites. Removing outdated favorites from config after favorites have been created. Testing that old-style favorited videos in the config are imported. Removing channels_by_link. Using list to store channels in config. Moving channel import function into lib. Supporting old channel import with links. Bumping version for channel.link removal. Removing all reference to Channel.link in app and api. Adding relative property to MediaPathType. Testing that a channel can be downloaded after it has a frequency added. All tests pass. Video and Channel tests pass without channel.link. Removing channel.link usage in channel api. Changing video Statistics page to About.
This commit is contained in:
parent
79efaa22b0
commit
aa203cc102
36 changed files with 1229 additions and 1308 deletions
|
|
@ -154,8 +154,8 @@ class ChannelPage extends APIForm {
|
|||
|
||||
async componentDidMount() {
|
||||
if (!this.props.create) {
|
||||
let channel_link = this.props.match.params.channel_link;
|
||||
let channel = await getChannel(channel_link);
|
||||
let channel_id = this.props.match.params.channel_id;
|
||||
let channel = await getChannel(channel_id);
|
||||
let statistics = channel.statistics;
|
||||
if (statistics) {
|
||||
this.setState({statistics: statistics || null});
|
||||
|
|
@ -173,7 +173,7 @@ class ChannelPage extends APIForm {
|
|||
|
||||
handleConfirm = async () => {
|
||||
this.setState({deleteOpen: false});
|
||||
let response = await deleteChannel(this.props.match.params.channel_link);
|
||||
let response = await deleteChannel(this.props.match.params.channel_id);
|
||||
if (response.status === 204) {
|
||||
this.props.history.push({
|
||||
pathname: '/videos/channel'
|
||||
|
|
@ -194,7 +194,7 @@ class ChannelPage extends APIForm {
|
|||
if (this.props.create) {
|
||||
response = await createChannel(inputs);
|
||||
} else {
|
||||
response = await updateChannel(this.props.match.params.channel_link, inputs);
|
||||
response = await updateChannel(this.props.match.params.channel_id, inputs);
|
||||
}
|
||||
|
||||
} finally {
|
||||
|
|
@ -215,7 +215,7 @@ class ChannelPage extends APIForm {
|
|||
this.setSuccess(
|
||||
'Channel created',
|
||||
<span>
|
||||
Your channel was created. View it <Link to={`/videos/channel/${channel.link}/edit`}>here</Link>
|
||||
Your channel was created. View it <Link to={`/videos/channel/${channel.id}/edit`}>here</Link>
|
||||
</span>
|
||||
);
|
||||
} else {
|
||||
|
|
@ -262,12 +262,12 @@ class ChannelPage extends APIForm {
|
|||
|
||||
downloadChannel = async (e) => {
|
||||
e.preventDefault();
|
||||
return await downloadChannel(this.props.match.params.channel_link);
|
||||
return await downloadChannel(this.props.match.params.channel_id);
|
||||
}
|
||||
|
||||
refreshChannel = async (e) => {
|
||||
e.preventDefault();
|
||||
return await refreshChannel(this.props.match.params.channel_link);
|
||||
return await refreshChannel(this.props.match.params.channel_id);
|
||||
}
|
||||
|
||||
handleDeleteButton = (e) => {
|
||||
|
|
@ -470,8 +470,8 @@ export function NewChannel(props) {
|
|||
class ChannelRow extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.editTo = `/videos/channel/${props.channel.link}/edit`;
|
||||
this.videosTo = `/videos/channel/${props.channel.link}/video`;
|
||||
this.editTo = `/videos/channel/${props.channel.id}/edit`;
|
||||
this.videosTo = `/videos/channel/${props.channel.id}/video`;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
@ -646,7 +646,7 @@ export class Channels extends React.Component {
|
|||
<Table striped basic size='large'>
|
||||
{tableHeader}
|
||||
<Table.Body>
|
||||
{this.state.results.map((channel) => <ChannelRow key={channel.link}
|
||||
{this.state.results.map((channel) => <ChannelRow key={channel.id}
|
||||
channel={channel}/>)}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
|
|
@ -655,7 +655,7 @@ export class Channels extends React.Component {
|
|||
<Table striped basic unstackable size='small'>
|
||||
<Table.Body>
|
||||
{this.state.results.map((channel) =>
|
||||
<MobileChannelRow key={channel.link} channel={channel}/>)}
|
||||
<MobileChannelRow key={channel.id} channel={channel}/>)}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Responsive>
|
||||
|
|
|
|||
|
|
@ -135,8 +135,8 @@ export function VideoCard({video}) {
|
|||
let channel = video.channel ? video.channel : null;
|
||||
let channel_url = null;
|
||||
if (channel) {
|
||||
channel_url = `/videos/channel/${channel.link}/video`;
|
||||
video_url = `/videos/channel/${channel.link}/video/${video.id}`;
|
||||
channel_url = `/videos/channel/${channel.id}/video`;
|
||||
video_url = `/videos/channel/${channel.id}/video/${video.id}`;
|
||||
}
|
||||
let poster_url = video.poster_path ? `/media/${encodeURIComponent(video.poster_path)}` : null;
|
||||
|
||||
|
|
|
|||
|
|
@ -76,8 +76,8 @@ function VideoPage(props) {
|
|||
</Tab.Pane>
|
||||
};
|
||||
|
||||
let statisticsPane = {
|
||||
menuItem: 'Statistics', render: () => <Tab.Pane>
|
||||
let aboutPane = {
|
||||
menuItem: 'About', render: () => <Tab.Pane>
|
||||
<h3>Size</h3>
|
||||
<p>{video.size ? humanFileSize(video.size) : '???'}</p>
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ function VideoPage(props) {
|
|||
</Tab.Pane>
|
||||
};
|
||||
|
||||
let tabPanes = [descriptionPane, statisticsPane, captionsPane];
|
||||
let tabPanes = [descriptionPane, aboutPane, captionsPane];
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -135,7 +135,7 @@ function VideoPage(props) {
|
|||
<h2>{video.title || video.video_path}</h2>
|
||||
{video.upload_date && <h3>{uploadDate(video.upload_date)}</h3>}
|
||||
<h3>
|
||||
{channel && <Link to={`/videos/channel/${channel.link}/video`}>
|
||||
{channel && <Link to={`/videos/channel/${channel.id}/video`}>
|
||||
{channel.name}
|
||||
</Link>}
|
||||
</h3>
|
||||
|
|
|
|||
|
|
@ -103,8 +103,8 @@ export class VideoWrapper extends React.Component {
|
|||
async fetchVideo() {
|
||||
// Get and display the Video specified in the Router match
|
||||
let [video, prev, next] = await getVideo(this.props.match.params.video_id);
|
||||
let channel_link = this.props.match.params.channel_link;
|
||||
let channel = channel_link ? await getChannel(channel_link) : null;
|
||||
let channel_id = this.props.match.params.channel_id;
|
||||
let channel = channel_id ? await getChannel(channel_id) : null;
|
||||
let no_channel = false;
|
||||
if (!channel) {
|
||||
no_channel = true;
|
||||
|
|
@ -222,7 +222,7 @@ class Videos extends React.Component {
|
|||
}
|
||||
|
||||
async componentDidMount() {
|
||||
if (this.props.match.params.channel_link) {
|
||||
if (this.props.match.params.channel_id) {
|
||||
await this.fetchChannel();
|
||||
} else {
|
||||
await this.fetchVideos();
|
||||
|
|
@ -233,7 +233,7 @@ class Videos extends React.Component {
|
|||
async componentDidUpdate(prevProps, prevState, snapshot) {
|
||||
let params = this.props.match.params;
|
||||
|
||||
let channelChanged = params.channel_link !== prevProps.match.params.channel_link;
|
||||
let channelChanged = params.channel_id !== prevProps.match.params.channel_id;
|
||||
let pageChanged = (
|
||||
prevState.activePage !== this.state.activePage ||
|
||||
prevState.searchOrder !== this.state.searchOrder ||
|
||||
|
|
@ -269,10 +269,10 @@ class Videos extends React.Component {
|
|||
|
||||
async fetchChannel() {
|
||||
// Get and display the channel specified in the Router match
|
||||
let channel_link = this.props.match.params.channel_link;
|
||||
let channel_id = this.props.match.params.channel_id;
|
||||
let channel = null;
|
||||
if (channel_link) {
|
||||
channel = await getChannel(channel_link);
|
||||
if (channel_id) {
|
||||
channel = await getChannel(channel_id);
|
||||
}
|
||||
this.setState({
|
||||
channel,
|
||||
|
|
@ -300,13 +300,13 @@ class Videos extends React.Component {
|
|||
async fetchVideos() {
|
||||
this.setState({videos: null});
|
||||
let offset = this.state.limit * this.state.activePage - this.state.limit;
|
||||
let channel_link = this.state.channel ? this.state.channel.link : null;
|
||||
let channel_id = this.state.channel ? this.state.channel.id : null;
|
||||
let {queryStr, searchOrder, limit} = this.state;
|
||||
|
||||
// Pass any enabled filters to the search.
|
||||
let filtersArr = this.enabledFilters();
|
||||
|
||||
let [videos, total] = await searchVideos(offset, limit, channel_link, queryStr, searchOrder, filtersArr);
|
||||
let [videos, total] = await searchVideos(offset, limit, channel_id, queryStr, searchOrder, filtersArr);
|
||||
|
||||
let totalPages = Math.round(total / this.state.limit) || 1;
|
||||
this.setState({videos, totalPages});
|
||||
|
|
@ -428,7 +428,7 @@ class Videos extends React.Component {
|
|||
<>
|
||||
|
||||
|
||||
<Link to={`/videos/channel/${channel.link}/edit`}>
|
||||
<Link to={`/videos/channel/${channel.id}/edit`}>
|
||||
<Icon name="edit"/>
|
||||
</Link>
|
||||
</>
|
||||
|
|
@ -527,7 +527,7 @@ export function VideosRoute(props) {
|
|||
<Route path='/videos/channel' exact component={Channels}/>
|
||||
<Route path='/videos/manage' exact component={ManageTab}/>
|
||||
<Route path='/videos/channel/new' exact component={NewChannel}/>
|
||||
<Route path='/videos/channel/:channel_link/edit' exact
|
||||
<Route path='/videos/channel/:channel_id/edit' exact
|
||||
component={(i) =>
|
||||
<EditChannel
|
||||
match={i.match}
|
||||
|
|
@ -535,7 +535,7 @@ export function VideosRoute(props) {
|
|||
/>
|
||||
}
|
||||
/>
|
||||
<Route path='/videos/channel/:channel_link/video' exact component={Videos}/>
|
||||
<Route path='/videos/channel/:channel_id/video' exact component={Videos}/>
|
||||
</PageContainer>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue